flockfile()

lock stdio (FILE *) objects 

Function


SYNOPSIS

#include <stdio.h>

void flockfile(FILE *file);


DESCRIPTION

The flockfile() function provides explicit application-level locking of stdio (FILE *) objects. This function can be used by a thread to delineate a sequence of I/O statements that are to be executed as unit. After flockfile() returns, the calling thread owns file.

Logically, there is a lock count associated with each (FILE *) object. This count is implicitly initialized to zero when the object is created. The object is unlocked when the count is zero. When the count is positive, a single thread owns the object. When flockfile() is called, if the count is zero or if the count is positive and the caller owns the object, the count is incremented. Otherwise, the calling thread is suspended, waiting for the count to return to zero. Each call to funlockfile() decrements the count. This allows matching calls to flockfile() and funlockfile() to be nested.

All functions that reference (FILE *) objects behave as if they use flockfile() and funlockfile() internally to obtain ownership of these objects, unless the documentation for the function explicitly indicates that the function operates on an unlocked object.


PARAMETERS

file 

File object to be locked.


RETURN VALUES

None.


CONFORMANCE

POSIX.1 (1996).


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
fclose(), fdopen(), fopen(), ftrylockfile(), funlockfile(), getc_unlocked(), getchar_unlocked(), putc_unlocked(), putchar_unlocked()


PTC MKS Toolkit 10.4 Documentation Build 39.