From cdcea6ceb6b2b75d64059aac2f9436e1d51ba629 Mon Sep 17 00:00:00 2001 From: Mark Johannes Date: Mon, 12 Aug 1996 17:21:04 +0000 Subject: _POSIX_Condition_variables_Signal_support: added setting mutex back to NULL if the queue has been emptied of waiting tasks. _POSIX_Condition_variables_Wait_support: added error check for different mutexesfor the same condition variable. Also added _Thread_queue_Enter_critical_section --- cpukit/posix/src/cond.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cpukit/posix') diff --git a/cpukit/posix/src/cond.c b/cpukit/posix/src/cond.c index 68ef709be1..03f2b67577 100644 --- a/cpukit/posix/src/cond.c +++ b/cpukit/posix/src/cond.c @@ -199,7 +199,7 @@ int pthread_cond_init( the_cond->process_shared = the_attr->process_shared; - the_cond->Mutex = 0; + the_cond->Mutex = (unsigned32) NULL; /* XXX some more initialization might need to go here */ _Thread_queue_Initialize( @@ -314,6 +314,8 @@ int _POSIX_Condition_variables_Signal_support( do { the_thread = _Thread_queue_Dequeue( &the_cond->Wait_queue ); + if ( !the_thread ) + the_cond->Mutex = (unsigned32) NULL; } while ( is_broadcast && the_thread ); return 0; } @@ -372,9 +374,8 @@ int _POSIX_Condition_variables_Wait_support( return EINVAL; case OBJECTS_LOCAL: - /* - * XXX: should be an error if cond->Mutex != mutex - */ + if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) ) + return EINVAL; status = pthread_mutex_unlock( mutex ); if ( !status ) @@ -382,7 +383,8 @@ int _POSIX_Condition_variables_Wait_support( the_cond->Mutex = *mutex; -/* XXX .. enter critical section .. */ + _Thread_queue_Enter_critical_section( &the_cond->Wait_queue ); + _Thread_queue_Enqueue( &the_cond->Wait_queue, 0 ); _Thread_Enable_dispatch(); -- cgit v1.2.3