From 95e09afa92c5d0522a0d04019ef6680796688896 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 17 Jul 2013 15:53:17 +0200 Subject: score: Avoid direct usage of _Thread_Executing Pass the executing thread as a function parameter. Obtain the executing thread inside a thread dispatch critical section to avoid problems on SMP. --- cpukit/score/src/coremutex.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'cpukit/score/src/coremutex.c') diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index a39b4efebf..8ea7d13a4d 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -27,7 +27,8 @@ CORE_mutex_Status _CORE_mutex_Initialize( CORE_mutex_Control *the_mutex, - CORE_mutex_Attributes *the_mutex_attributes, + Thread_Control *executing, + const CORE_mutex_Attributes *the_mutex_attributes, uint32_t initial_lock ) { @@ -43,21 +44,21 @@ CORE_mutex_Status _CORE_mutex_Initialize( if ( initial_lock == CORE_MUTEX_LOCKED ) { the_mutex->nest_count = 1; - the_mutex->holder = _Thread_Executing; - the_mutex->holder_id = _Thread_Executing->Object.id; + the_mutex->holder = executing; + the_mutex->holder_id = executing->Object.id; if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) || _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ) { - if ( _Thread_Executing->current_priority < + if ( executing->current_priority < the_mutex->Attributes.priority_ceiling ) return CORE_MUTEX_STATUS_CEILING_VIOLATED; #ifdef __RTEMS_STRICT_ORDER_MUTEX__ - _Chain_Prepend_unprotected( &_Thread_Executing->lock_mutex, + _Chain_Prepend_unprotected( &executing->lock_mutex, &the_mutex->queue.lock_queue ); - the_mutex->queue.priority_before = _Thread_Executing->current_priority; + the_mutex->queue.priority_before = executing->current_priority; #endif - _Thread_Executing->resource_count++; + executing->resource_count++; } } else { the_mutex->nest_count = 0; -- cgit v1.2.3