Chapter 19. Synchronization

The FILEIO infrastructure provides a synchronization mechanism for controlling concurrent access to filesystems. This allows existing filesystems to be ported to eCos, even if they do not have their own synchronization mechanisms. It also allows new filesystems to be implemented easily without having to consider the synchronization issues.

The infrastructure maintains a mutex for each entry in each of the main tables: filesystem table, mount table and file table. For each class of operation each of these mutexes may be locked before the corresponding filesystem operation is invoked.

The synchronization protocol required by a filesystem is described by the syncmode field of the filesystem table entry. This is a combination of the following flags:

CYG_SYNCMODE_FILE_FILESYSTEM

Lock the filesystem table entry mutex during all filesystem level operations.

CYG_SYNCMODE_FILE_MOUNTPOINT

Lock the mount table entry mutex during all filesystem level operations.

CYG_SYNCMODE_IO_FILE

Lock the file table entry mutex during all I/O operations.

CYG_SYNCMODE_IO_FILESYSTEM

Lock the filesystem table entry mutex during all I/O operations.

CYG_SYNCMODE_IO_MOUNTPOINT

Lock the mount table entry mutex during all I/O operations.

CYG_SYNCMODE_SOCK_FILE

Lock the file table entry mutex during all socket operations.

CYG_SYNCMODE_SOCK_NETSTACK

Lock the network stack table entry mutex during all socket operations.

CYG_SYNCMODE_NONE

Perform no locking at all during any operations.

The value of the syncmode field in the filesystem table entry will be copied by the infrastructure to the open file object after a successful open() operation.