cvs commit: src/usr.bin/lockf lockf.c

Christian S.J. Peron csjp at FreeBSD.org
Sat Nov 12 13:00:01 PST 2005


csjp        2005-11-12 21:00:00 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_6)
    usr.bin/lockf        lockf.c 
  Log:
  Sync with head:
  
  -style(9) nits
  
  MFC Log:
    Fix long standing race condition associated with how lockf uses open(2)
    for mutual exclusion:
  
    A brief description of the problem:
  
            1) Proc A picks up non-blocking lock on file X
            2) Proc B attempts to pickup lock, fails then waits
            3) Proc C attempts to pickup lock, fails then waits
            4) Proc A releases lock
            5) Proc B acquires lock, release it to pickup a non-blocking version
            6) Proc C acquires lock, release it to pickup a non-blocking version
            7) Both process B and C race each other to pickup lock again
  
    This occurs mainly because the processes do not keep the lock after they have
    been waiting on it. They drop it, attempt to re-acquire it. (They use the wait
    to notify when the lock has become available then race to pick it up). This
    results in additional CPU utilization during the race, and can also result
    in processes picking locks up out of order.
  
    This change attempts to correct this problem by eliminating the test/acquire
    race and having the operating system handle it.
  
  Revision  Changes    Path
  1.11.8.1  +93 -130   src/usr.bin/lockf/lockf.c


More information about the cvs-all mailing list