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.
The lockf(2) function is not documented under FreeBSD, presumably because it was a System V ...