cvs commit: src/sys/conf files options src/sys/kern kern_rwlock.c subr_lock.c src/sys/sys lock.h rwlock.h

John Baldwin jhb at FreeBSD.org
Fri Jan 27 15:13:27 PST 2006


jhb         2006-01-27 23:13:26 UTC

  FreeBSD src repository

  Modified files:
    sys/conf             files options 
    sys/kern             subr_lock.c 
    sys/sys              lock.h 
  Added files:
    sys/kern             kern_rwlock.c 
    sys/sys              rwlock.h 
  Log:
  Add a basic reader/writer lock implementation to the kernel.  This
  implementation is by no means perfect as far as some of the algorithms
  that it uses and the fact that it is missing some functionality (try
  locks and upgrades/downgrades are not there yet), however it does seem
  to work in my local testing.  There is more detail in the comments in the
  code, but the short version follows.
  
  A reader/writer lock is very much like a regular mutex: it cannot be held
  across a voluntary sleep; it can be acquired in an interrupt thread; if
  the lock is held by a writer then the priority of any threads that block
  on the lock will be lent to the owner; the simple case lock operations all
  are done in a single atomic op.  It also shares some similiarities
  with sx locks: it supports reader/writer semantics (multiple readers,
  but single writers); readers are allowed to recurse, but writers are not.
  
  We can extend this implementation further by either improving algorithms
  or adding new functionality, but this should at least give us a base to
  work with now.
  
  Reviewed by:    arch (in theory)
  Tested on:      i386 (4 cpu box with a kernel module that used 4 threads
                  that randomly chose between read locks and write locks
                  that ran w/o panicing for over a day solid.  It usually
                  panic'd within a few seconds when there were bugs during
                  testing. :)  The kernel module source is available on
                  request.)
  
  Revision  Changes    Path
  1.1087    +1 -0      src/sys/conf/files
  1.525     +1 -0      src/sys/conf/options
  1.1       +587 -0    src/sys/kern/kern_rwlock.c (new)
  1.4       +1 -0      src/sys/kern/subr_lock.c
  1.58      +1 -0      src/sys/sys/lock.h
  1.1       +192 -0    src/sys/sys/rwlock.h (new)


More information about the cvs-src mailing list