svn commit: r356120 - head/sys/security/mac

Hans Petter Selasky hps at selasky.org
Fri Dec 27 11:51:31 UTC 2019


On 2019-12-27 12:33, Ronald Klop wrote:
> Wow, this looks like a winner.
> 
> Ronald.

Is this a spin-off from epoch methodology?

It is possible to use epoch as a part of read mostly locking too.

The basic idea here is to have a variable/refcount which when set, 
fallback to a regular mutex during read-locking. This is all 
synchronized under epoch.

Pseudo code:

read_lock() {
epoch_enter();
do_lock = writers != 0;
if (do_lock)
   mtx_lock();
}

read_unlock() {
if (do_lock)
  mtx_unlock();
epoch_exit();
}


write_lock() {
writers++;
epoch_wait();
mtx_lock();
}

write_unlock() {
mtx_unlock();
writers--;
epoch_wait();
}

--HPS


More information about the svn-src-all mailing list