cvs commit: src/sys/kern kern_mutex.c kern_sx.c subr_witness.c src/sys/sys lock.h

John Baldwin jhb at FreeBSD.org
Wed Jan 28 12:39:59 PST 2004


jhb         2004/01/28 12:39:57 PST

  FreeBSD src repository

  Modified files:
    sys/kern             kern_mutex.c kern_sx.c subr_witness.c 
    sys/sys              lock.h 
  Log:
  Rework witness_lock() to make it slightly more useful and flexible.
  - witness_lock() is split into two pieces: witness_checkorder() and
    witness_lock().  Witness_checkorder() determines if acquiring a specified
    lock at the time it is called would result in a lock order.  It
    optionally adds a new lock order relationship as well.  witness_lock()
    updates witness's data structures to assume that a lock has been acquired
    by stick a new lock instance in the appropriate lock instance list.
  - The mutex and sx lock functions now call checkorder() prior to trying to
    acquire a lock and continue to call witness_lock() after the acquire is
    completed.  This will let witness catch a deadlock before it happens
    rather than trying to do so after the threads have deadlocked (i.e. never
    actually report it).
  - A new function witness_defineorder() has been added that adds a lock
    order between two locks at runtime without having to acquire the locks.
    If the lock order cannot be added it will return an error.  This function
    is available to programmers via the WITNESS_DEFINEORDER() macro which
    accepts either two mutexes or two sx locks as its arguments.
  - A few simple wrapper macros were added to allow developers to call
    witness_checkorder() anywhere as a way of enforcing locking assertions
    in code that might acquire a certain lock in some situations.  The
    macros are: witness_check_{mutex,shared_sx,exclusive_sx} and take an
    appropriate lock as the sole argument.
  - The code to remove a lock instance from a lock list in witness_unlock()
    was unnested by using a goto to vastly improve the readability of this
    function.
  
  Revision  Changes    Path
  1.136     +4 -0      src/sys/kern/kern_mutex.c
  1.21      +3 -0      src/sys/kern/kern_sx.c
  1.167     +180 -108  src/sys/kern/subr_witness.c
  1.50      +27 -0     src/sys/sys/lock.h


More information about the cvs-src mailing list