Linux File lock
Linux File locks are divided into two types:
One is advasory lock, which can only ensure the mutual exclusion of the same file lock in the process. However, multiple processes can simultaneously Add a mutually exclusive lock to a file, therefore, this lock is applied to the file structure. One is the mandatory lock, which ensures that multiple processes cannot add mutex locks to the same file, therefore, this lock is applied to the inode structure.
When mandatroy lock is added, if the existing process adds mutex lock a to the file, the file_lock B structure created by the process will be added to the waiting list of A. At this time, a is called blocker, B is called waiter. Because the resources (locks) required by the process cannot be met, the process is either blocked, and the descriptor of the process is added to the waiting list of B; or an error is returned directly when a system call is performed. (Depends on the flag value during the call)