Understanding Lock Types
There are two basic forms of file locking. They are
Lock files
Locked regions
The first form requires that a process create and open a lock file before it writes to the protected data file. If a process fails to create the lock file, then it sleeps for a while and tries again.
For example, if the data file database.dat is the data file, then the lock file might be named database.lck. The contents of the lock file are not important to the procedure, and it may even be empty. When the updating process has finished with its update of database.dat, then the lock file database.lck is released. This method works only when all processes cooperate and obey this procedure.
The UNIX kernel also will permit a process to lock regions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access