Skip to content

Commit 054d938

Browse files
committed
Merge pull request swiftlang#58 from frankeh/thmgmt_inform
inform libpwq thread manager before semaphore wait
2 parents 79fbb13 + 112e1ed commit 054d938

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/semaphore.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
383383
uint64_t nsec = _dispatch_timeout(timeout);
384384
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
385385
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
386+
pthread_workqueue_signal_np();
386387
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
387388
} while (ret == false && errno == EINTR);
388389

@@ -430,6 +431,7 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
430431
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
431432
#elif USE_FUTEX_SEM
432433
do {
434+
pthread_workqueue_signal_np();
433435
ret = _dispatch_futex_wait(&dsema->dsema_futex, NULL);
434436
} while (ret == false && errno == EINTR);
435437
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
@@ -648,6 +650,7 @@ _dispatch_group_wait_slow(dispatch_semaphore_t dsema, dispatch_time_t timeout)
648650
uint64_t nsec = _dispatch_timeout(timeout);
649651
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
650652
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
653+
pthread_workqueue_signal_np();
651654
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
652655
} while (ret == false && errno == EINTR);
653656

@@ -695,6 +698,7 @@ _dispatch_group_wait_slow(dispatch_semaphore_t dsema, dispatch_time_t timeout)
695698
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
696699
#elif USE_FUTEX_SEM
697700
do {
701+
pthread_workqueue_signal_np();
698702
ret = _dispatch_futex_wait(&dsema->dsema_futex, NULL);
699703
} while (ret == false && errno == EINTR);
700704
DISPATCH_SEMAPHORE_VERIFY_RET(ret);

0 commit comments

Comments
 (0)