mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Improve lock hierarchy
- NetBSD no longer needs a spin lock to create semaphores - Windows fork() now locks process manager in correct order
This commit is contained in:
parent
7ba9a73840
commit
d3a13e8d70
14 changed files with 73 additions and 71 deletions
|
@ -117,18 +117,21 @@ errno_t pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
|||
if (MUTEX_PSHARED(muword) != PTHREAD_PROCESS_SHARED)
|
||||
return EINVAL;
|
||||
|
||||
errno_t err;
|
||||
BEGIN_CANCELATION_POINT;
|
||||
#if PTHREAD_USE_NSYNC
|
||||
// favor *NSYNC if this is a process private condition variable
|
||||
// if using Mike Burrows' code isn't possible, use a naive impl
|
||||
if (!cond->_pshared)
|
||||
return nsync_cv_wait_with_deadline(
|
||||
if (!cond->_pshared) {
|
||||
err = nsync_cv_wait_with_deadline(
|
||||
(nsync_cv *)cond, (nsync_mu *)mutex,
|
||||
abstime ? *abstime : nsync_time_no_deadline, 0);
|
||||
#endif
|
||||
|
||||
errno_t err;
|
||||
BEGIN_CANCELATION_POINT;
|
||||
} else {
|
||||
err = pthread_cond_timedwait_impl(cond, mutex, abstime);
|
||||
}
|
||||
#else
|
||||
err = pthread_cond_timedwait_impl(cond, mutex, abstime);
|
||||
#endif
|
||||
END_CANCELATION_POINT;
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue