summaryrefslogtreecommitdiff
path: root/sem_timedwait.c
diff options
context:
space:
mode:
authorrpj <rpj>2004-10-19 13:24:40 +0000
committerrpj <rpj>2004-10-19 13:24:40 +0000
commit8c8bcc5d1737002a9d153105c16b262d2e201efa (patch)
treeba43c6049cc7e361a3eb875015aeb4032c01c559 /sem_timedwait.c
parent45b1b8cb2a6588f9316f780d8cefe11c181a9a17 (diff)
Semaphore speedups - alpha, but passes testsuite
Diffstat (limited to 'sem_timedwait.c')
-rw-r--r--sem_timedwait.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sem_timedwait.c b/sem_timedwait.c
index e374006..e7fa55c 100644
--- a/sem_timedwait.c
+++ b/sem_timedwait.c
@@ -189,7 +189,15 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
#else /* NEED_SEM */
- result = (pthreadCancelableTimedWait ((*sem)->sem, milliseconds));
+ if (InterlockedDecrement((LPLONG) &(*sem)->value) < 0)
+ {
+ /* Must wait */
+ result = pthreadCancelableTimedWait ((*sem)->sem, milliseconds);
+ if (result != 0)
+ {
+ (void) InterlockedIncrement((LPLONG) &(*sem)->value);
+ }
+ }
#endif