From: yeom Date: Wed, 17 Nov 2010 03:40:43 +0000 (+0000) Subject: grabs a lock when it tries to reset X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ac9babd769c4c4d509feda5bdb22e708dc722731;p=IRC.git grabs a lock when it tries to reset --- diff --git a/Robust/src/Runtime/psemaphore.c b/Robust/src/Runtime/psemaphore.c index 64cdda50..05c7a155 100644 --- a/Robust/src/Runtime/psemaphore.c +++ b/Robust/src/Runtime/psemaphore.c @@ -42,12 +42,8 @@ void psem_give_tag( psemaphore* sem, int tag) { void psem_reset( psemaphore* sem ) { - // this should NEVER BE CALLED if it is possible - // the semaphore is still in use, NEVER - if( pthread_mutex_trylock( &(sem->lock) ) == EBUSY ) { - exit( -1 ); - } - pthread_mutex_unlock( &(sem->lock) ); + pthread_mutex_lock ( &(sem->lock) ); sem->tag++; sem->signaled = 0; + pthread_mutex_unlock( &(sem->lock) ); }