Writing
The
associated with an open for writing is the "mutating" counterpart of
the
associated with an open for reading. The command is similar:
open(f,WRITING,
)
When a file, f (as in the above command), is opened for writing
and
is the specified time bound, then the following "rules" apply:
- If

0 then f must be and remain consistent within
the specified time bound. This is pessimistic writing.
- Note: In this case consistency should be thought of as:
The file is not updated on the server by other clients. The replica, on the
client that opens the file for writing, of course do not stay consistent
(because it is written to), but it will "merge" successfully with the primary
copy if it reaches the server before the lock expires--so in this sense it
is consistent.
- If
=0 then f must be consistent (now). This is
strict writing.
- If

0 then f is guaranteed to have been consistent
no longer ago then specified by the time bound and on last check. This
is optimistic writing.
- Note: Compared to reads the file is additionally required to have
been consistent on the last check (i.e.,
=
), for else the writing is
bound to fail (it is inconsistent even before it is begone).
As with the
the
should be thought of as a system
guarantee and the user or the application may end up doing better--e.g., if
available bandwidth is used intelligently!
The correspondence between the modification time bound
and the level of optimism or pessimism when opening a file for writing is depicted
in Figure 5.2.
Figure 5.2:
Modification Time Bound (MTB)
 |
The primitive for open for writing is the ANSI-C [21] fopen
with an added parameter for specifying the modification time bound:
- ANSI-C: FILE *fopen(char *pathname,char *mode);
- mode
{"r+","r+b","w","wb","w+","w+b","a","ab",
"a+","a+b"}
-




: FILE *p_open(char *pathname,char *mode,int mtb);
michael@garfield.dk
2000-10-13