]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - fatfs/documents/doc/sync.html
Import fatfs R0.15
[z180-stamp.git] / fatfs / documents / doc / sync.html
index a0317d6da10fb4fe8d81c54b18d276e8b18084f9..9fb42a090737678685ecd646645443ec99339012 100644 (file)
@@ -44,7 +44,30 @@ FRESULT f_sync (
 \r
 <div class="para desc">\r
 <h4>Description</h4>\r
-<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function of periodic or immediataly after <tt>f_write</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>\r
+<p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function in certain interval can minimize the risk of data loss due to a sudden blackout, wrong media removal or unrecoverable disk error. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>\r
+<pre>\r
+Case 1. Normal write sequence\r
+\r
+                                Time --&gt;                                     ↓Normal shutdown\r
+OwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwC &lt;Power off&gt;\r
+\r
+\r
+Case 2. Without using f_sync()\r
+\r
+                                Time --&gt;                             ↓System crush\r
+O<span class="e">wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww</span>\r
+ |&lt;--------------- All data written will be lost ------------------&gt;|\r
+\r
+\r
+Case 3. Using f_sync()\r
+                                Time --&gt;                             ↓System crush\r
+OwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwSwwwwwwwwS<span class="e">wwwww</span>\r
+                            Data after last f_sync will be lost |&lt;-&gt;| \r
+O - f_open()\r
+C - f_close()\r
+w - f_write()\r
+S - f_sync()\r
+</pre>\r
 <p>However there is no sense in <tt>f_sync</tt> function immediataly before <tt>f_close</tt> function because it performs <tt>f_sync</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>\r
 </div>\r
 \r