O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Record Locking

The BSD flock(2) approach provides improved performance over the lock file but still suffers from the fact that it locks the entire file.

Even better performance can be obtained when the regions of the file are locked instead of the entire file. System V provided the lockf(2) function to accomplish this. Later, POSIX defined yet another application interface using the fcntl(2) function.

To visualize locked regions, review Figure 5.1, in which three processes successfully obtained region locks. The execution of the fourth process was suspended because its request to lock a region overlapped with another granted lock.

Locking with lockf(2)

The lockf(2) function is not documented under FreeBSD, presumably because it was a System V ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required