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:
Justine Tunney 2024-07-24 15:55:57 -07:00
parent 7ba9a73840
commit d3a13e8d70
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
14 changed files with 73 additions and 71 deletions

View file

@ -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;
}