forked from Imagelibrary/rtems
posix: Use mutex object itself for condvar
We should only use the address used to initialize the mutex object according to POSIX, "2.9.9 Synchronization Object Copies and Alternative Mappings". http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09_09 Update #3113.
This commit is contained in:
@@ -43,7 +43,7 @@ extern "C" {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
Objects_Control Object;
|
Objects_Control Object;
|
||||||
Thread_queue_Control Wait_queue;
|
Thread_queue_Control Wait_queue;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t *mutex;
|
||||||
clockid_t clock;
|
clockid_t clock;
|
||||||
} POSIX_Condition_variables_Control;
|
} POSIX_Condition_variables_Control;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ extern "C" {
|
|||||||
* Constant to indicate condition variable does not currently have
|
* Constant to indicate condition variable does not currently have
|
||||||
* a mutex assigned to it.
|
* a mutex assigned to it.
|
||||||
*/
|
*/
|
||||||
#define POSIX_CONDITION_VARIABLES_NO_MUTEX 0
|
#define POSIX_CONDITION_VARIABLES_NO_MUTEX NULL
|
||||||
|
|
||||||
#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
|
#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static void _POSIX_Condition_variables_Enqueue_callout(
|
|||||||
|
|
||||||
the_cond = POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue );
|
the_cond = POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue );
|
||||||
|
|
||||||
mutex_error = pthread_mutex_unlock( &the_cond->mutex );
|
mutex_error = pthread_mutex_unlock( the_cond->mutex );
|
||||||
if ( mutex_error != 0 ) {
|
if ( mutex_error != 0 ) {
|
||||||
/*
|
/*
|
||||||
* Historically, we ignored the unlock status since the behavior
|
* Historically, we ignored the unlock status since the behavior
|
||||||
@@ -107,13 +107,13 @@ int _POSIX_Condition_variables_Wait_support(
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
the_cond->mutex != POSIX_CONDITION_VARIABLES_NO_MUTEX
|
the_cond->mutex != POSIX_CONDITION_VARIABLES_NO_MUTEX
|
||||||
&& the_cond->mutex != *mutex
|
&& the_cond->mutex != mutex
|
||||||
) {
|
) {
|
||||||
_POSIX_Condition_variables_Release( the_cond, &queue_context );
|
_POSIX_Condition_variables_Release( the_cond, &queue_context );
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
the_cond->mutex = *mutex;
|
the_cond->mutex = mutex;
|
||||||
executing = _Thread_Executing;
|
executing = _Thread_Executing;
|
||||||
|
|
||||||
if ( !already_timedout ) {
|
if ( !already_timedout ) {
|
||||||
@@ -135,7 +135,7 @@ int _POSIX_Condition_variables_Wait_support(
|
|||||||
} else {
|
} else {
|
||||||
_POSIX_Condition_variables_Release( the_cond, &queue_context );
|
_POSIX_Condition_variables_Release( the_cond, &queue_context );
|
||||||
|
|
||||||
mutex_error = pthread_mutex_unlock( &the_cond->mutex );
|
mutex_error = pthread_mutex_unlock( the_cond->mutex );
|
||||||
if ( mutex_error != 0 ) {
|
if ( mutex_error != 0 ) {
|
||||||
error = EPERM;
|
error = EPERM;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user