Пример #1
0
void _CORE_mutex_Seize_interrupt_blocking(
  CORE_mutex_Control  *the_mutex,
  Thread_Control      *executing,
  Watchdog_Interval    timeout,
  ISR_lock_Context    *lock_context
)
{
#if !defined(RTEMS_SMP)
  /*
   * We must disable thread dispatching here since we enable the interrupts for
   * priority inheritance mutexes.
   */
  _Thread_Dispatch_disable();
#endif

  if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) {
    Thread_Control *holder = the_mutex->holder;

#if !defined(RTEMS_SMP)
    /*
     * To enable interrupts here works only since exactly one executing thread
     * exists and only threads are allowed to seize and surrender mutexes with
     * the priority inheritance protocol.  On SMP configurations more than one
     * executing thread may exist, so here we must not release the lock, since
     * otherwise the current holder may be no longer the holder of the mutex
     * once we released the lock.
     */
    _Thread_queue_Release( &the_mutex->Wait_queue, lock_context );
#endif

    _Thread_Inherit_priority( holder, executing );

#if !defined(RTEMS_SMP)
    _Thread_queue_Acquire( &the_mutex->Wait_queue, lock_context );
#endif
  }

  _Thread_queue_Enqueue_critical(
    &the_mutex->Wait_queue.Queue,
    the_mutex->operations,
    executing,
    STATES_WAITING_FOR_MUTEX,
    timeout,
    CORE_MUTEX_TIMEOUT,
    lock_context
  );

#if !defined(RTEMS_SMP)
  _Thread_Dispatch_enable( _Per_CPU_Get() );
#endif
}
Пример #2
0
static void _Mutex_Acquire_slow(
  Mutex_Control     *mutex,
  Thread_Control    *owner,
  Thread_Control    *executing,
  Watchdog_Interval  timeout,
  ISR_lock_Context  *lock_context
)
{
  _Thread_Inherit_priority( owner, executing );
  _Thread_queue_Enqueue_critical(
    &mutex->Queue.Queue,
    MUTEX_TQ_OPERATIONS,
    executing,
    STATES_WAITING_FOR_SYS_LOCK_MUTEX,
    timeout,
    ETIMEDOUT,
    lock_context
  );
}