From c5e340c71ba6f4563ca5fa245baa82b6363ddb2e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 29 Oct 1998 15:17:25 +0000 Subject: Update. 1998-10-29 Ulrich Drepper * sysdeps/unix/sysv/linux/ttyname_r.c (ttyname_r): Try reading /prof/self/fd/FD first. * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Likewise. * stdio-common/_itoa.h (_fitoa_word): New inline function. Write formatted number starting at given position and return pointer to following byte. (_fitoa): Likewise, for long long. --- linuxthreads/semaphore.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'linuxthreads/semaphore.c') diff --git a/linuxthreads/semaphore.c b/linuxthreads/semaphore.c index af5f115..cb23a71 100644 --- a/linuxthreads/semaphore.c +++ b/linuxthreads/semaphore.c @@ -40,15 +40,14 @@ int sem_init(sem_t *sem, int pshared, unsigned int value) int sem_wait(sem_t * sem) { - volatile pthread_descr self; + volatile pthread_descr self = thread_self(); - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); if (sem->sem_value > 0) { sem->sem_value--; __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); return 0; } - self = thread_self(); enqueue(&sem->sem_waiting, self); /* Wait for sem_post or cancellation */ __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); @@ -57,7 +56,7 @@ int sem_wait(sem_t * sem) if (THREAD_GETMEM(self, p_canceled) && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) { /* Remove ourselves from the waiting list if we're still on it */ - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); remove_from_queue(&sem->sem_waiting, self); __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); pthread_exit(PTHREAD_CANCELED); @@ -70,7 +69,7 @@ int sem_trywait(sem_t * sem) { int retval; - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, NULL); if (sem->sem_value == 0) { errno = EAGAIN; retval = -1; @@ -88,7 +87,7 @@ int sem_post(sem_t * sem) struct pthread_request request; if (THREAD_GETMEM(self, p_in_sighandler) == NULL) { - __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock); + __pthread_lock((struct _pthread_fastlock *) &sem->sem_lock, self); if (sem->sem_waiting == NULL) { if (sem->sem_value >= SEM_VALUE_MAX) { /* Overflow */ -- cgit v1.1