diff options
author | mtm <mtm@FreeBSD.org> | 2003-05-12 10:48:02 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2003-05-12 10:48:02 +0000 |
commit | 071fc87f0a558d8dd08feb1e4b7d005d7064a740 (patch) | |
tree | be034a0aebe03655e1b3a5ffd432a7eeddef8c10 /sys/kern/subr_power.c | |
parent | 48426a5b69ebb2c0acedf34d5c273286bb757c1c (diff) | |
download | FreeBSD-src-071fc87f0a558d8dd08feb1e4b7d005d7064a740.zip FreeBSD-src-071fc87f0a558d8dd08feb1e4b7d005d7064a740.tar.gz |
Forced commit, for previous revision.
Make state transitions of a thread on a mutex queue
atomic (with respect to other threads and signal handlers).
This includes:
o Introduce two functions to implement atomicity with respect
to other threads and signal handlers. Basically,
_thread_critical_enter() locks the calling thread and blocks
signals. _thread_critical_exit() unblocks signals and unlocks
the thread.
o Introduce two new functions:
get_muncontested() locks a mutex that is not owned by
another thread.
get_mcontested() places a thread on a contested mutex's
queue, taking care to use the _thread_critical_enter/exit
functions to protect thread state.
o Modify mutex_unlock_common() to also protect state transitions.
In this case it needs the cooperation of mutex_queue_deq(), which
must return with the thread locked and signals disabled *before*
it takes the thread off the queue.
Combine _pthread_mutex_lock() and _pthread_mutex_trylock()
into one function: mutex_lock_common(), that can handle
both cases. Its behaviour is controlled by an argument,
int nonblock, which if not zero means do not attempt
to acquire a contested mutex if the uncontested case fails.
BTW, when I write about contested and uncontested mutexes, I'm writing
about it from the application's point of view. I'm not writing about
internal locking of pthread_mutex->lock, which is achieved differently.
While internal mutex locking is mostly done, there's still a bit more
work left in this area.
Approved by: markm/mentor, re/blanket libthr
Reviewed by: jeff (slightly diff. revision)
Diffstat (limited to 'sys/kern/subr_power.c')
0 files changed, 0 insertions, 0 deletions