FAT | RFS | XFS | ZFS

fcb_lock()

PROTOTYPE

#include <stdio.h>

void fcb_lock(FILE *file);

DESCRIPTION

fcb_lock() reserves a volume for exclusive access by the currently running task. If another task tries to access the volume, it will block until fcb_unlock() is called to release the volume.

fcb_lock() and fcb_unlock() support multitasking applications. If a task needs to update a file using multiple writes, these calls ensure these writes are not interspersed by writes from other tasks.

EXAMPLE

  /*-------------------------------------------------------------------*/
  /* Reserve volume for use by just this task.                         */
  /*-------------------------------------------------------------------*/
  fcb_lock(file);

  /*-------------------------------------------------------------------*/
  /* Write the string one character at a time.                         */
  /*-------------------------------------------------------------------*/
  while (*str)
    fputc(*str++, file);

  /*-------------------------------------------------------------------*/
  /* Release volume for use by other tasks.                            */
  /*-------------------------------------------------------------------*/
  fcb_unlock(file);