Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Mar 2003 12:17:00 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/sys/kern subr_eventhandler.c src/sys/sys eventhandler.h
Message-ID:  <200303112017.h2BKH0NB073797@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
jhb         2003/03/11 12:17:00 PST

  FreeBSD src repository

  Modified files:
    sys/kern             subr_eventhandler.c 
    sys/sys              eventhandler.h 
  Log:
  Rework the eventhandler locking for hopefully the last time.  The scheme
  used popped into my head during my morning commute a few weeks ago, but
  it is also very similar (though a bit simpler) to a patch that mini@
  developed a while ago.  Basically, each eventhandler list has a mutex and
  a run count.  During an eventhandler invocation, the mutex is held while
  we traverse the list but is dropped while we execute actual handlers.  Also,
  a runcount counter is incremented at the start of an invocation and
  decremented at the end of an invocation.  Adding to the list is not a big
  deal since the reference of a thread currently executing the handlers
  remains valid across an add operation.  Whether or not new handlers are
  executed by threads currently executing the handlers for a given list is
  indeterminate however.  The harder case is when a handler is removed from
  the list.  If the runcount is zero, the handler is simply removed from the
  list directly.  If the runcount is not zero, then another thread is
  currently executing the handlers of this list, so the priority of this
  handler is set to a magic value (currently -1) to mark it as dead.  Dead
  handlers are not executed during an invocation.  If the runcount is zero
  after it is decremented at the end of an invocation, then a new
  eventhandler_prune_list() function is called to remove dead handlers from
  the list.
  
  Additional minor notes:
  - All the common parts of EVENTHANDLER_INVOKE() and
    EVENTHANDLER_FAST_INVOKE() have been merged into a common
    _EVENTHANDLER_INVOKE() macro to reduce duplication and ease maintenance.
  - KTR logging for eventhandlers is now available via the KTR_EVH mask.
  - The global eventhander_mutex is no longer recursive.
  
  Tested by:      scottl (SMP i386)
  
  Revision  Changes    Path
  1.20      +108 -41   src/sys/kern/subr_eventhandler.c
  1.26      +62 -43    src/sys/sys/eventhandler.h

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-src" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303112017.h2BKH0NB073797>