Tag Archives: api

vfs_lock_file – file byte range lock

1. vfs_lock_file – file byte range lock

2. Manual

 int vfs_lock_file(struct file * filp, unsigned int cmd, struct file_lock * fl, struct file_lock * conf);

 filp
           The file to apply the lock to

       cmd
           type of locking operation (F_SETLK, F_GETLK, etc.)

       fl
           The lock to be applied

       conf
           Place to return a copy of the conflicting lock, if found.



mutex_init .

1. mutex_init

Initialize the mutex to unlocked state.

2. Classroom

The point of a mutex  is to synchronize two threads. When
you  have  two  threads  attempting to  access  a  single
resource, the general pattern  is to have the first block
of  code  attempting  access  to  set  the  mutex  before
entering the  code. When  the second code  block attempts
access,  it sees  the mutex  is set  and waits  until the
first block of code  is complete (and un-sets the mutex),
then continues.

source : http://stackoverflow.com/questions/34524/what-is-a-mutex