Implement msleep(). This function is similar to the FreeBSD msleep() except
authorMatthew Dillon <dillon@dragonflybsd.org>
Sat, 27 May 2006 01:51:27 +0000 (01:51 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Sat, 27 May 2006 01:51:27 +0000 (01:51 +0000)
commitbf7652876b1a585b2e56512cf16b9bfddaf092a1
tree99e528dca2da6acb26486bbc24dc6aae81fc83fb
parent9ba4b5177f44ceead7a091e07b6645537aa807b7
Implement msleep().  This function is similar to the FreeBSD msleep() except
it interlocks with a spinlock instead of a mutex.  The spinlock must be
exclusively held on entry.  msleep() will atomically sleep and release the
spinlock, then reacquire the spinlock when it wakes up.

A novel approach to the interlock is used.  DragonFly's tsleep/wakeup
mechanism is a per-cpu mechanism, with a local array of cpu masks, one
entry per hash index.  A wakeup simpy sends an IPI message to each target
cpu whos bitmap bit is set in the ident's hash entry.

This allows us to interlock simply by entering a critical section and
setting our bit, then releasing the mutex, then tsleep()ing as per normal.
No additional locks are required.  The critical section will delay any wakeup
race with us simply by delaying the IPI message that is potentially
in-transit to our cpu.

Requested-by: Numerous people, and its time has come now.
sys/kern/kern_synch.c
sys/sys/systm.h