summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorMark Johannes <Mark.Johannes@OARcorp.com>1996-08-13 19:03:29 +0000
committerMark Johannes <Mark.Johannes@OARcorp.com>1996-08-13 19:03:29 +0000
commit76f03c642c4844e4ee0c781f381e9f60f86adf5c (patch)
treeebfdeb25f6e940bd3ece0ce0fb95d4fbe6d2c25f /c
parentfixed spacing (diff)
downloadrtems-76f03c642c4844e4ee0c781f381e9f60f86adf5c.tar.bz2
_POSIX_Condition_variables_Wait_support: fixed the timeout sequence.
Diffstat (limited to 'c')
-rw-r--r--c/src/exec/posix/src/cond.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/c/src/exec/posix/src/cond.c b/c/src/exec/posix/src/cond.c
index 955c8f01c2..3f53e53ead 100644
--- a/c/src/exec/posix/src/cond.c
+++ b/c/src/exec/posix/src/cond.c
@@ -200,7 +200,7 @@ int pthread_cond_init(
the_cond->process_shared = the_attr->process_shared;
- the_cond->Mutex = (unsigned32) NULL;
+ the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
/* XXX some more initialization might need to go here */
_Thread_queue_Initialize(
@@ -316,8 +316,11 @@ int _POSIX_Condition_variables_Signal_support(
do {
the_thread = _Thread_queue_Dequeue( &the_cond->Wait_queue );
if ( !the_thread )
- the_cond->Mutex = (unsigned32) NULL;
+ the_cond->Mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
} while ( is_broadcast && the_thread );
+
+ _Thread_Enable_dispatch();
+
return 0;
}
return POSIX_BOTTOM_REACHED();
@@ -375,21 +378,36 @@ int _POSIX_Condition_variables_Wait_support(
return EINVAL;
case OBJECTS_LOCAL:
- if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) )
+ if ( the_cond->Mutex && ( the_cond->Mutex != *mutex ) ) {
+ _Thread_Enable_dispatch();
return EINVAL;
+ }
+
+ the_cond->Mutex = *mutex;
status = pthread_mutex_unlock( mutex );
- if ( status )
+ if ( status ) {
+ _Thread_Enable_dispatch();
return status;
-
- the_cond->Mutex = *mutex;
+ }
_Thread_queue_Enter_critical_section( &the_cond->Wait_queue );
+ _Thread_Executing->Wait.return_code = 0;
+ _Thread_Executing->Wait.queue = &the_cond->Wait_queue;
+ _Thread_Executing->Wait.id = *cond;
- _Thread_queue_Enqueue( &the_cond->Wait_queue, 0 );
+ _Thread_queue_Enqueue( &the_cond->Wait_queue, timeout );
_Thread_Enable_dispatch();
+ /*
+ * Switch ourself out because we blocked as a result of the
+ * _Thread_queue_Enqueue.
+ */
+
+ if ( _Thread_Executing->Wait.return_code )
+ return _Thread_Executing->Wait.return_code;
+
status = pthread_mutex_lock( mutex );
if ( status )
return status;