flockfile(3S) SDK R4.11 flockfile(3S)
NAME
flockfile, funlockfile - synchronize stdio file operations for
reentrant functions
SYNOPSIS
#include <stdio.h>
void flockfile(FILE *file);
void funlockfile(FILE *file);
DESCRIPTION
flockfile and funlockfile provide for explicit application level
locking and unlocking of stdio (FILE *) objects. They may be used by
a thread to delineate a sequence of I/O statements that are to be
executed as a unit.
The flockfile function is used by a thread to advise the
implementation that it is the current owner of a (FILE *) object.
The funlockfile function is used to relinquish the ownership granted
to the thread. The behavior is undefined if a thread other than the
current owner calls the funlockfile function.
Logically, there is a lock count associated with each (FILE *)
object. This count is implicitly initialized to zero when the file
is opened. The (FILE *) object is unlocked when this count is zero.
When the count is positive a single thread owns the (FILE *) object.
Each call to funlockfile decrements the count.
When the count is non-zero threads not owning the (FILE *) object
suspend waiting for the count to return to zero. The thread owning
the (FILE *) object does not suspend on subsequent calls to
flockfile. This allows matching calls to flockfile and funlockfile
to be nested.
Considerations for Threads Programming
+------------+-----------------------------+
| | async- |
|function | reentrant cancel cancel |
| | point safe |
+------------+-----------------------------+
|flockfile | Y N N |
|funlockfile | Y N N |
+------------+-----------------------------+
The flockfile and funlockfile functions are only useful in a threaded
applications.
DIAGNOSTICS
There are no return values or errors.
SEE ALSO
getcunlocked(3S), getcharunlocked(3S), and reentrant(3).
STANDARDS
These functions are not available when using m88kbcs, m88kdguxcoff,
or m88kocs as the Software Development Environment targets.
Licensed material--property of copyright holder(s)