Core mutex seize method
Andrei Dimitrief-Jianu
andrei.dimitrief.jianu at gmail.com
Fri Oct 26 18:43:41 UTC 2012
rHello,
Below is an excerpt from cpukit/score/inline/rtems/score/coremutex.inl.
Can anyone argue that the first 'if' statement is not thread safe?
What is the condition that prevents the executing thread from being
preempted by another thread,
a thread that might compete for the same mutex, right before executing
the_mutex->lock = CORE_MUTEX_LOCKED;?
Thanks,
Andrei.
[...]
RTEMS_INLINE_ROUTINE int _CORE_mutex_Seize_interrupt_trylock_body(
CORE_mutex_Control *the_mutex,
ISR_Level *level_p
)
{
Thread_Control *executing;
/* disabled when you get here */
executing = _Thread_Executing;
executing->Wait.return_code = CORE_MUTEX_STATUS_SUCCESSFUL;
if ( !_CORE_mutex_Is_locked( the_mutex ) ) {
the_mutex->lock = CORE_MUTEX_LOCKED;
the_mutex->holder = executing;
the_mutex->holder_id = executing->Object.id;
the_mutex->nest_count = 1;
if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ||
_CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ) ){
#ifdef __RTEMS_STRICT_ORDER_MUTEX__
_Chain_Prepend_unprotected( &executing->lock_mutex,
&the_mutex->queue.lock_queue );
the_mutex->queue.priority_before = executing->current_priority;
#endif
executing->resource_count++;
}
[...]
More information about the devel
mailing list