...
Each file actually has a lock count associated with it. This allows nested calls by a task to acquire a file lock; each of those calls must be matched with a call to fs_funlockfile(
). Listing - Example file lock usage shows how the file lock functions can be used.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
void App_Fnct (void)
{
unsigned char data1[50];
unsigned char data2[10];
.
.
.
if (App_FilePtr != (FS_FILE *)0) { (1)
fs_flockfile(App_FilePtr); /* Lock file. */
/* Wr data atomically. */
fs_fwrite(data1, 1, sizeof(data1), App_FilePtr);
fs_fwrite(data2, 1, sizeof(data1), App_FilePtr);
fs_funlockfile(App_FilePtr); /* Unlock file. */
}
.
.
.
} |
Panel |
---|
(1) |