Changeset fef3ea9 in rtems


Ignore:
Timestamp:
Aug 11, 2016, 6:32:49 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
a827447
Parents:
03c1038
git-author:
Sebastian Huber <sebastian.huber@…> (08/11/16 06:32:49)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/11/16 09:13:36)
Message:

score: Add _Thread_queue_Surrender()

Add _Thread_queue_Surrender() to unify the mutex surrender procedures
which involve a thread queue operation.

Location:
cpukit/score
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r03c1038 rfef3ea9  
    184184## CORE_MUTEX_C_FILES
    185185libscore_a_SOURCES += src/coremutexseize.c
    186 libscore_a_SOURCES += src/coremutexsurrender.c
    187186
    188187## CORE_PERCPU_C_FILES
  • cpukit/score/include/rtems/score/coremuteximpl.h

    r03c1038 rfef3ea9  
    115115);
    116116
    117 Status_Control _CORE_mutex_Surrender_slow(
    118   CORE_mutex_Control   *the_mutex,
    119   Thread_Control       *executing,
    120   Thread_queue_Heads   *heads,
    121   bool                  keep_priority,
    122   Thread_queue_Context *queue_context
    123 );
    124 
    125117RTEMS_INLINE_ROUTINE void _CORE_mutex_Set_owner(
    126118  CORE_mutex_Control *the_mutex,
     
    263255  }
    264256
    265   return _CORE_mutex_Surrender_slow(
    266     &the_mutex->Mutex,
     257  _Thread_queue_Surrender(
     258    &the_mutex->Mutex.Wait_queue.Queue,
     259    CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
     260    heads,
    267261    executing,
    268     heads,
    269262    keep_priority,
    270263    queue_context
    271264  );
     265  return STATUS_SUCCESSFUL;
    272266}
    273267
  • cpukit/score/include/rtems/score/threadqimpl.h

    r03c1038 rfef3ea9  
    710710void _Thread_queue_Extract_with_proxy(
    711711  Thread_Control       *the_thread
     712);
     713
     714/**
     715 * @brief Surrenders the thread queue previously owned by the thread to the
     716 * first enqueued thread if it exists.
     717 *
     718 * The owner of the thread queue must be set to NULL by the caller.
     719 *
     720 * This function releases the thread queue lock.  In addition it performs a
     721 * thread dispatch if necessary.
     722 *
     723 * @param[in] queue The actual thread queue.
     724 * @param[in] operations The thread queue operations.
     725 * @param[in] heads The thread queue heads.
     726 * @param[in] previous_owner The previous owner thread surrendering the thread
     727 *   queue.
     728 * @param[in] keep_priority Indicates if the previous owner thread should keep
     729 *   its current priority.
     730 * @param[in] queue_context The thread queue context of the lock acquire.
     731 */
     732void _Thread_queue_Surrender(
     733  Thread_queue_Queue            *queue,
     734  const Thread_queue_Operations *operations,
     735  Thread_queue_Heads            *heads,
     736  Thread_Control                *previous_owner,
     737  bool                           keep_priority,
     738  Thread_queue_Context          *queue_context
    712739);
    713740
  • cpukit/score/src/mutex.c

    r03c1038 rfef3ea9  
    122122}
    123123
    124 static void _Mutex_Release_slow(
    125   Mutex_Control        *mutex,
    126   Thread_Control       *executing,
    127   Thread_queue_Heads   *heads,
    128   bool                  keep_priority,
    129   Thread_queue_Context *queue_context
    130 )
    131 {
    132   if (heads != NULL) {
    133     const Thread_queue_Operations *operations;
    134     Thread_Control                *first;
    135     bool                           unblock;
    136 
    137     operations = MUTEX_TQ_OPERATIONS;
    138     first = ( *operations->first )( heads );
    139 
    140     mutex->Queue.Queue.owner = first;
    141     ++first->resource_count;
    142     _Thread_queue_Boost_priority( &mutex->Queue.Queue, first );
    143     unblock = _Thread_queue_Extract_locked(
    144       &mutex->Queue.Queue,
    145       operations,
    146       first,
    147       queue_context
    148     );
    149     _Thread_queue_Unblock_critical(
    150       unblock,
    151       &mutex->Queue.Queue,
    152       first,
    153       &queue_context->Lock_context
    154     );
    155   } else {
    156     _Mutex_Queue_release( mutex, queue_context );
    157   }
    158 
    159   if ( !keep_priority ) {
    160     Per_CPU_Control *cpu_self;
    161 
    162     cpu_self = _Thread_Dispatch_disable();
    163     _Thread_Restore_priority( executing );
    164     _Thread_Dispatch_enable( cpu_self );
    165   }
    166 }
    167 
    168124static void _Mutex_Release_critical(
    169125  Mutex_Control        *mutex,
     
    193149    _Mutex_Queue_release( mutex, queue_context );
    194150  } else {
    195     _Mutex_Release_slow(
    196       mutex,
     151    _Thread_queue_Surrender(
     152      &mutex->Queue.Queue,
     153      MUTEX_TQ_OPERATIONS,
     154      heads,
    197155      executing,
    198       heads,
    199156      keep_priority,
    200157      queue_context
  • cpukit/score/src/threadqenqueue.c

    r03c1038 rfef3ea9  
    569569}
    570570
     571void _Thread_queue_Surrender(
     572  Thread_queue_Queue            *queue,
     573  const Thread_queue_Operations *operations,
     574  Thread_queue_Heads            *heads,
     575  Thread_Control                *previous_owner,
     576  bool                           keep_priority,
     577  Thread_queue_Context          *queue_context
     578)
     579{
     580  if ( heads != NULL ) {
     581    Thread_Control *new_owner;
     582    bool            unblock;
     583
     584    new_owner = ( *operations->first )( heads );
     585    queue->owner = new_owner;
     586
     587#if defined(RTEMS_MULTIPROCESSING)
     588    if ( _Objects_Is_local_id( new_owner->Object.id ) )
     589#endif
     590    {
     591      ++new_owner->resource_count;
     592      _Thread_queue_Boost_priority( queue, new_owner );
     593    }
     594
     595    unblock = _Thread_queue_Extract_locked(
     596      queue,
     597      operations,
     598      new_owner,
     599      queue_context
     600    );
     601
     602    _Thread_queue_Unblock_critical(
     603      unblock,
     604      queue,
     605      new_owner,
     606      &queue_context->Lock_context
     607    );
     608  } else {
     609    _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
     610  }
     611
     612  if ( !keep_priority ) {
     613    Per_CPU_Control *cpu_self;
     614
     615    cpu_self = _Thread_Dispatch_disable();
     616    _Thread_Restore_priority( previous_owner );
     617    _Thread_Dispatch_enable( cpu_self );
     618  }
     619}
     620
    571621Thread_Control *_Thread_queue_Do_dequeue(
    572622  Thread_queue_Control          *the_thread_queue,
Note: See TracChangeset for help on using the changeset viewer.