Пример #1
0
static void _Mutex_Release_critical(
  Mutex_Control        *mutex,
  Thread_Control       *executing,
  ISR_Level             level,
  Thread_queue_Context *queue_context
)
{
  Thread_queue_Heads *heads;

  heads = mutex->Queue.Queue.heads;
  mutex->Queue.Queue.owner = NULL;
  _Thread_Resource_count_decrement( executing );

  if ( __predict_true( heads == NULL ) ) {
    _Mutex_Queue_release( mutex, level, queue_context );
  } else {
    _Thread_queue_Context_set_ISR_level( queue_context, level );
    _Thread_queue_Surrender(
      &mutex->Queue.Queue,
      heads,
      executing,
      queue_context,
      MUTEX_TQ_OPERATIONS
    );
  }
}
Пример #2
0
static void _Mutex_Release_critical(
  Mutex_Control        *mutex,
  Thread_Control       *executing,
  Thread_queue_Context *queue_context
)
{
  Thread_queue_Heads *heads;
  bool keep_priority;

  mutex->Queue.Queue.owner = NULL;

  --executing->resource_count;

  /*
   * Ensure that the owner resource count is visible to all other
   * processors and that we read the latest priority restore
   * hint.
   */
  _Atomic_Fence( ATOMIC_ORDER_ACQ_REL );

  heads = mutex->Queue.Queue.heads;
  keep_priority = _Thread_Owns_resources( executing )
    || !executing->priority_restore_hint;

  if ( __predict_true( heads == NULL && keep_priority ) ) {
    _Mutex_Queue_release( mutex, queue_context );
  } else {
    _Thread_queue_Surrender(
      &mutex->Queue.Queue,
      MUTEX_TQ_OPERATIONS,
      heads,
      executing,
      keep_priority,
      queue_context
    );
  }
}