From ac9babd769c4c4d509feda5bdb22e708dc722731 Mon Sep 17 00:00:00 2001 From: yeom Date: Wed, 17 Nov 2010 03:40:43 +0000 Subject: [PATCH] grabs a lock when it tries to reset --- Robust/src/Runtime/psemaphore.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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) ); } -- 2.34.1