Core mutex seize method
Gedare Bloom
gedare at rtems.org
Fri Oct 26 19:11:00 UTC 2012
iirc it is the caller's responsibility to disable dispatching or
interrupts prior to calling CORE_mutex_Seize
On Fri, Oct 26, 2012 at 2:43 PM, Andrei Dimitrief-Jianu
<andrei.dimitrief.jianu at gmail.com> wrote:
> 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++;
> }
>
> [...]
> _______________________________________________
> rtems-devel mailing list
> rtems-devel at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-devel
More information about the devel
mailing list