<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>Synchronization</TITLE
|
>Synchronization</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="File System Support Infrastructure"
|
TITLE="File System Support Infrastructure"
|
HREF="fileio.html"><LINK
|
HREF="fileio.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Directories"
|
TITLE="Directories"
|
HREF="fileio-directories.html"><LINK
|
HREF="fileio-directories.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Initialization and Mounting"
|
TITLE="Initialization and Mounting"
|
HREF="fileio-mounting.html"></HEAD
|
HREF="fileio-mounting.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="fileio-directories.html"
|
HREF="fileio-directories.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="fileio-mounting.html"
|
HREF="fileio-mounting.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
><H1
|
><H1
|
><A
|
><A
|
NAME="FILEIO-SYNCHRONIZATION">Chapter 24. Synchronization</H1
|
NAME="FILEIO-SYNCHRONIZATION">Chapter 24. Synchronization</H1
|
><P
|
><P
|
>The FILEIO infrastructure provides a synchronization mechanism for
|
>The FILEIO infrastructure provides a synchronization mechanism for
|
controlling concurrent access to filesystems. This allows existing
|
controlling concurrent access to filesystems. This allows existing
|
filesystems to be ported to eCos, even if they do not have their own
|
filesystems to be ported to eCos, even if they do not have their own
|
synchronization mechanisms. It also allows new filesystems to be
|
synchronization mechanisms. It also allows new filesystems to be
|
implemented easily without having to consider the synchronization
|
implemented easily without having to consider the synchronization
|
issues.</P
|
issues.</P
|
><P
|
><P
|
>The infrastructure maintains a mutex for each entry in each of
|
>The infrastructure maintains a mutex for each entry in each of
|
the main tables: filesystem table, mount table and file table. For
|
the main tables: filesystem table, mount table and file table. For
|
each class of operation each of these mutexes may be locked before the
|
each class of operation each of these mutexes may be locked before the
|
corresponding filesystem operation is invoked.</P
|
corresponding filesystem operation is invoked.</P
|
><P
|
><P
|
>The synchronization protocol required by a filesystem is described
|
>The synchronization protocol required by a filesystem is described
|
by the <TT
|
by the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>syncmode</I
|
>syncmode</I
|
></TT
|
></TT
|
> field of the filesystem
|
> field of the filesystem
|
table entry. This is a combination of the following flags:</P
|
table entry. This is a combination of the following flags:</P
|
><P
|
><P
|
></P
|
></P
|
><DIV
|
><DIV
|
CLASS="VARIABLELIST"
|
CLASS="VARIABLELIST"
|
><DL
|
><DL
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_FILE_FILESYSTEM</TT
|
>CYG_SYNCMODE_FILE_FILESYSTEM</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the filesystem table entry mutex
|
>Lock the filesystem table entry mutex
|
during all filesystem level operations.</P
|
during all filesystem level operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_FILE_MOUNTPOINT</TT
|
>CYG_SYNCMODE_FILE_MOUNTPOINT</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the mount table entry mutex
|
>Lock the mount table entry mutex
|
during all filesystem level operations.</P
|
during all filesystem level operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_IO_FILE</TT
|
>CYG_SYNCMODE_IO_FILE</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the file table entry mutex during all
|
>Lock the file table entry mutex during all
|
I/O operations.</P
|
I/O operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_IO_FILESYSTEM</TT
|
>CYG_SYNCMODE_IO_FILESYSTEM</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the filesystem table entry mutex during all I/O operations.</P
|
>Lock the filesystem table entry mutex during all I/O operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_IO_MOUNTPOINT</TT
|
>CYG_SYNCMODE_IO_MOUNTPOINT</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the mount table entry mutex during all I/O operations.</P
|
>Lock the mount table entry mutex during all I/O operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_SOCK_FILE</TT
|
>CYG_SYNCMODE_SOCK_FILE</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the file table entry mutex during all socket operations.</P
|
>Lock the file table entry mutex during all socket operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_SOCK_NETSTACK</TT
|
>CYG_SYNCMODE_SOCK_NETSTACK</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Lock the network stack table entry mutex during all socket operations.</P
|
>Lock the network stack table entry mutex during all socket operations.</P
|
></DD
|
></DD
|
><DT
|
><DT
|
><TT
|
><TT
|
CLASS="LITERAL"
|
CLASS="LITERAL"
|
>CYG_SYNCMODE_NONE</TT
|
>CYG_SYNCMODE_NONE</TT
|
></DT
|
></DT
|
><DD
|
><DD
|
><P
|
><P
|
>Perform no locking at all during any operations.</P
|
>Perform no locking at all during any operations.</P
|
></DD
|
></DD
|
></DL
|
></DL
|
></DIV
|
></DIV
|
><P
|
><P
|
>The value of the <TT
|
>The value of the <TT
|
CLASS="STRUCTFIELD"
|
CLASS="STRUCTFIELD"
|
><I
|
><I
|
>syncmode</I
|
>syncmode</I
|
></TT
|
></TT
|
> field in the
|
> field in the
|
filesystem table entry will be copied by the infrastructure to the
|
filesystem table entry will be copied by the infrastructure to the
|
open file object after a successful <TT
|
open file object after a successful <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>open()</TT
|
>open()</TT
|
> operation.</P
|
> operation.</P
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio-directories.html"
|
HREF="fileio-directories.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio-mounting.html"
|
HREF="fileio-mounting.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Directories</TD
|
>Directories</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="fileio.html"
|
HREF="fileio.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Initialization and Mounting</TD
|
>Initialization and Mounting</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|