Changeset 9bfad8c in rtems


Ignore:
Timestamp:
Jun 8, 2016, 8:22:46 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
006af6ac
Parents:
69a6802b
git-author:
Sebastian Huber <sebastian.huber@…> (06/08/16 20:22:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/22/16 12:44:56)
Message:

score: Add thread priority to scheduler nodes

The thread priority is manifest in two independent areas. One area is
the user visible thread priority along with a potential thread queue.
The other is the scheduler. Currently, a thread priority update via
_Thread_Change_priority() first updates the user visble thread priority
and the thread queue, then the scheduler is notified if necessary. The
priority is passed to the scheduler via a local variable. A generation
counter ensures that the scheduler discards out-of-date priorities.

This use of a local variable ties the update in these two areas close
together. For later enhancements and the OMIP locking protocol
implementation we need more flexibility. Add a thread priority
information block to Scheduler_Node and synchronize priority value
updates via a sequence lock on SMP configurations.

Update #2556.

Files:
3 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r69a6802b r9bfad8c  
    235235libscore_a_SOURCES += src/schedulerdefaultstartidle.c
    236236libscore_a_SOURCES += src/schedulerdefaulttick.c
    237 libscore_a_SOURCES += src/schedulerdefaultupdate.c
    238237
    239238## SCHEDULERPRIORITY_C_FILES
     
    243242    src/schedulerpriorityschedule.c \
    244243    src/schedulerpriorityunblock.c \
    245     src/schedulerpriorityupdate.c \
    246244    src/schedulerpriorityyield.c
    247245
     
    262260    src/scheduleredfschedule.c \
    263261    src/scheduleredfunblock.c \
    264     src/scheduleredfupdate.c \
    265262    src/scheduleredfyield.c
    266263
  • cpukit/score/include/rtems/score/scheduler.h

    r69a6802b r9bfad8c  
    2121
    2222#include <rtems/score/priority.h>
     23#include <rtems/score/smplockseq.h>
    2324#include <rtems/score/thread.h>
    2425#if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP)
     
    8485  );
    8586
    86   /** @see _Scheduler_Change_priority() */
    87   Scheduler_Void_or_thread ( *change_priority )(
    88     const Scheduler_Control *,
    89     Thread_Control *,
    90     Priority_Control,
    91     bool
     87  /** @see _Scheduler_Update_priority() */
     88  Scheduler_Void_or_thread ( *update_priority )(
     89    const Scheduler_Control *,
     90    Thread_Control *
    9291  );
    9392
     
    130129
    131130  /** @see _Scheduler_Node_initialize() */
    132   void ( *node_initialize )( const Scheduler_Control *, Thread_Control * );
     131  void ( *node_initialize )(
     132    const Scheduler_Control *,
     133    Thread_Control *,
     134    Priority_Control
     135  );
    133136
    134137  /** @see _Scheduler_Node_destroy() */
    135138  void ( *node_destroy )( const Scheduler_Control *, Thread_Control * );
    136 
    137   /** @see _Scheduler_Update_priority() */
    138   void ( *update_priority )(
    139     const Scheduler_Control *,
    140     Thread_Control *,
    141     Priority_Control
    142   );
    143139
    144140  /** @see _Scheduler_Release_job() */
     
    339335  Thread_Control *accepts_help;
    340336#endif
     337
     338  /**
     339   * @brief The thread priority information used by the scheduler.
     340   *
     341   * The thread priority is manifest in two independent areas.  One area is the
     342   * user visible thread priority along with a potential thread queue.  The
     343   * other is the scheduler.  During a thread priority change, the user visible
     344   * thread priority and the thread queue are first updated and the thread
     345   * priority value here is changed.  Once this is done the scheduler is
     346   * notified via the update priority operation, so that it can update its
     347   * internal state and honour a new thread priority value.
     348   */
     349  struct {
     350    /**
     351     * @brief The thread priority value of this scheduler node.
     352     *
     353     * The producer of this value is _Thread_Change_priority().  The consumer
     354     * is the scheduler via the unblock and update priority operations.
     355     */
     356    Priority_Control value;
     357
     358#if defined(RTEMS_SMP)
     359    /**
     360     * @brief Sequence lock to synchronize priority value updates.
     361     */
     362    SMP_sequence_lock_Control Lock;
     363#endif
     364
     365    /**
     366     * @brief In case a priority update is necessary and this is true, then
     367     * enqueue the thread as the first of its priority group, otherwise enqueue
     368     * the thread as the last of its priority group.
     369     */
     370    bool prepend_it;
     371  } Priority;
    341372};
    342373
     
    465496
    466497/**
    467  * @brief Does nothing.
     498 * @brief Performs the scheduler base node initialization.
    468499 *
    469500 * @param[in] scheduler Unused.
    470501 * @param[in] the_thread Unused.
     502 * @param[in] priority The thread priority.
    471503 */
    472504void _Scheduler_default_Node_initialize(
    473505  const Scheduler_Control *scheduler,
    474   Thread_Control          *the_thread
     506  Thread_Control          *the_thread,
     507  Priority_Control         priority
    475508);
    476509
     
    484517  const Scheduler_Control *scheduler,
    485518  Thread_Control          *the_thread
    486 );
    487 
    488 /**
    489  * @brief Does nothing.
    490  *
    491  * @param[in] scheduler Unused.
    492  * @param[in] the_thread Unused.
    493  * @param[in] new_priority Unused.
    494  */
    495 void _Scheduler_default_Update_priority(
    496   const Scheduler_Control *scheduler,
    497   Thread_Control          *the_thread,
    498   Priority_Control         new_priority
    499519);
    500520
  • cpukit/score/include/rtems/score/schedulercbs.h

    r69a6802b r9bfad8c  
    5555    _Scheduler_EDF_Block,            /* block entry point */ \
    5656    _Scheduler_CBS_Unblock,          /* unblock entry point */ \
    57     _Scheduler_EDF_Change_priority,  /* change priority entry point */ \
     57    _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
    5858    _Scheduler_EDF_Map_priority,     /* map priority entry point */ \
    5959    _Scheduler_EDF_Unmap_priority,   /* unmap priority entry point */ \
     
    6161    _Scheduler_CBS_Node_initialize,  /* node initialize entry point */ \
    6262    _Scheduler_default_Node_destroy, /* node destroy entry point */ \
    63     _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
    6463    _Scheduler_CBS_Release_job,      /* new period of task */ \
    6564    _Scheduler_default_Tick,         /* tick entry point */ \
     
    347346void _Scheduler_CBS_Node_initialize(
    348347  const Scheduler_Control *scheduler,
    349   Thread_Control          *the_thread
     348  Thread_Control          *the_thread,
     349  Priority_Control         priority
    350350);
    351351
  • cpukit/score/include/rtems/score/scheduleredf.h

    r69a6802b r9bfad8c  
    4848    _Scheduler_EDF_Block,            /* block entry point */ \
    4949    _Scheduler_EDF_Unblock,          /* unblock entry point */ \
    50     _Scheduler_EDF_Change_priority,  /* change priority entry point */ \
     50    _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
    5151    _Scheduler_EDF_Map_priority,     /* map priority entry point */ \
    5252    _Scheduler_EDF_Unmap_priority,   /* unmap priority entry point */ \
     
    5454    _Scheduler_EDF_Node_initialize,  /* node initialize entry point */ \
    5555    _Scheduler_default_Node_destroy, /* node destroy entry point */ \
    56     _Scheduler_EDF_Update_priority,  /* update priority entry point */ \
    5756    _Scheduler_EDF_Release_job,      /* new period of task */ \
    5857    _Scheduler_default_Tick,         /* tick entry point */ \
     
    157156 *  @param[in] scheduler The scheduler instance.
    158157 *  @param[in] the_thread being initialized.
     158 *  @param[in] priority The thread priority.
    159159 */
    160160void _Scheduler_EDF_Node_initialize(
    161161  const Scheduler_Control *scheduler,
    162   Thread_Control          *the_thread
    163 );
    164 
    165 /**
    166  *  @brief Updates position in the ready queue of @a the_thread.
    167  *
    168  *  This routine updates position in the ready queue of @a the_thread.
    169  *
    170  *  @param[in] scheduler The scheduler instance.
    171  *  @param[in] the_thread will have its scheduler specific information
    172  *             structure updated.
    173  *  @param[in] new_priority is the desired new priority.
    174  */
    175 void _Scheduler_EDF_Update_priority(
    176   const Scheduler_Control *scheduler,
    177162  Thread_Control          *the_thread,
    178   Priority_Control         new_priority
     163  Priority_Control         priority
    179164);
    180165
     
    194179);
    195180
    196 Scheduler_Void_or_thread _Scheduler_EDF_Change_priority(
    197   const Scheduler_Control *scheduler,
    198   Thread_Control          *the_thread,
    199   Priority_Control         new_priority,
    200   bool                     prepend_it
     181Scheduler_Void_or_thread _Scheduler_EDF_Update_priority(
     182  const Scheduler_Control *scheduler,
     183  Thread_Control          *the_thread
    201184);
    202185
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r69a6802b r9bfad8c  
    342342 * @brief Unblocks a thread with respect to the scheduler.
    343343 *
    344  * This routine adds @a the_thread to the scheduling decision for
    345  * the scheduler.  The primary task is to add the thread to the
    346  * ready queue per the schedulering policy and update any appropriate
    347  * scheduling variables, for example the heir thread.
     344 * This operation must fetch the latest thread priority value for this
     345 * scheduler instance and update its internal state if necessary.
    348346 *
    349347 * @param[in] the_thread The thread.
     348 *
     349 * @see _Scheduler_Node_get_priority().
    350350 */
    351351RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread )
     
    375375 * @brief Propagates a priority change of a thread to the scheduler.
    376376 *
    377  * The caller must ensure that the thread is in the ready state.  The caller
    378  * must ensure that the priority value actually changed and is not equal to the
    379  * current priority value.
     377 * On uni-processor configurations, this operation must evaluate the thread
     378 * state.  In case the thread is not ready, then the priority update should be
     379 * deferred to the next scheduler unblock operation.
    380380 *
    381381 * The operation must update the heir and thread dispatch necessary variables
     
    383383 *
    384384 * @param[in] the_thread The thread changing its priority.
    385  * @param[in] new_priority The new thread priority.
    386  * @param[in] prepend_it In case this is true, then enqueue the thread as the
    387  * first of its priority group, otherwise enqueue the thread as the last of its
    388  * priority group.
    389  */
    390 RTEMS_INLINE_ROUTINE void _Scheduler_Change_priority(
    391   Thread_Control          *the_thread,
    392   Priority_Control         new_priority,
    393   bool                     prepend_it
    394 )
     385 *
     386 * @see _Scheduler_Node_get_priority().
     387 */
     388RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread )
    395389{
    396390  const Scheduler_Control *own_scheduler;
     
    406400  needs_help =
    407401#endif
    408   ( *own_scheduler->Operations.change_priority )(
    409     own_scheduler,
    410     the_thread,
    411     new_priority,
    412     prepend_it
    413   );
     402  ( *own_scheduler->Operations.update_priority )( own_scheduler, the_thread );
    414403
    415404#if defined(RTEMS_SMP)
     
    467456 * @param[in] scheduler The scheduler instance.
    468457 * @param[in] the_thread The thread containing the scheduler node.
     458 * @param[in] priority The thread priority.
    469459 */
    470460RTEMS_INLINE_ROUTINE void _Scheduler_Node_initialize(
    471461  const Scheduler_Control *scheduler,
    472   Thread_Control          *the_thread
    473 )
    474 {
    475   return ( *scheduler->Operations.node_initialize )( scheduler, the_thread );
     462  Thread_Control          *the_thread,
     463  Priority_Control         priority
     464)
     465{
     466  ( *scheduler->Operations.node_initialize )(
     467    scheduler,
     468    the_thread,
     469    priority
     470  );
    476471}
    477472
     
    491486{
    492487  ( *scheduler->Operations.node_destroy )( scheduler, the_thread );
    493 }
    494 
    495 /**
    496  * @brief Updates the scheduler about a priority change of a not ready thread.
    497  *
    498  * @param[in] the_thread The thread.
    499  * @param[in] new_priority The new priority of the thread.
    500  */
    501 RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority(
    502   Thread_Control   *the_thread,
    503   Priority_Control  new_priority
    504 )
    505 {
    506   const Scheduler_Control *scheduler;
    507   ISR_lock_Context         lock_context;
    508 
    509   scheduler = _Scheduler_Get( the_thread );
    510   _Scheduler_Acquire_critical( scheduler, &lock_context );
    511 
    512   ( *scheduler->Operations.update_priority )(
    513     scheduler,
    514     the_thread,
    515     new_priority
    516   );
    517 
    518   _Scheduler_Release_critical( scheduler, &lock_context );
    519488}
    520489
     
    640609  the_thread->Scheduler.own_control = scheduler;
    641610  the_thread->Scheduler.control = scheduler;
    642   _Scheduler_Node_initialize( scheduler, the_thread );
    643   _Scheduler_Update_priority( the_thread, the_thread->current_priority );
     611  _Scheduler_Node_initialize(
     612    scheduler,
     613    the_thread,
     614    the_thread->current_priority
     615  );
    644616
    645617  if ( _States_Is_ready( current_state ) ) {
     
    828800
    829801RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize(
    830   Scheduler_Node *node,
    831   Thread_Control *the_thread
    832 )
    833 {
     802  Scheduler_Node   *node,
     803  Thread_Control   *the_thread,
     804  Priority_Control  priority
     805)
     806{
     807  node->Priority.value = priority;
     808  node->Priority.prepend_it = false;
     809
    834810#if defined(RTEMS_SMP)
    835811  node->user = the_thread;
     
    838814  node->idle = NULL;
    839815  node->accepts_help = the_thread;
     816  _SMP_sequence_lock_Initialize( &node->Priority.Lock );
    840817#else
    841   (void) node;
    842818  (void) the_thread;
     819#endif
     820}
     821
     822RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority(
     823  Scheduler_Node *node,
     824  bool           *prepend_it_p
     825)
     826{
     827  Priority_Control priority;
     828  bool             prepend_it;
     829
     830#if defined(RTEMS_SMP)
     831  unsigned int     seq;
     832
     833  do {
     834    seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock );
     835#endif
     836
     837    priority = node->Priority.value;
     838    prepend_it = node->Priority.prepend_it;
     839
     840#if defined(RTEMS_SMP)
     841  } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) );
     842#endif
     843
     844  *prepend_it_p = prepend_it;
     845
     846  return priority;
     847}
     848
     849RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority(
     850  Scheduler_Node   *node,
     851  Priority_Control  new_priority,
     852  bool              prepend_it
     853)
     854{
     855#if defined(RTEMS_SMP)
     856  unsigned int seq;
     857
     858  seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock );
     859#endif
     860
     861  node->Priority.value = new_priority;
     862  node->Priority.prepend_it = prepend_it;
     863
     864#if defined(RTEMS_SMP)
     865  _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq );
    843866#endif
    844867}
  • cpukit/score/include/rtems/score/schedulerpriority.h

    r69a6802b r9bfad8c  
    4545    _Scheduler_priority_Block,            /* block entry point */ \
    4646    _Scheduler_priority_Unblock,          /* unblock entry point */ \
    47     _Scheduler_priority_Change_priority,  /* change priority entry point */ \
     47    _Scheduler_priority_Update_priority,  /* update priority entry point */ \
    4848    _Scheduler_default_Map_priority,      /* map priority entry point */ \
    4949    _Scheduler_default_Unmap_priority,    /* unmap priority entry point */ \
    5050    SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
    51     _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
     51    _Scheduler_priority_Node_initialize,  /* node initialize entry point */ \
    5252    _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
    53     _Scheduler_priority_Update_priority,  /* update priority entry point */ \
    5453    _Scheduler_default_Release_job,       /* new period of task */ \
    5554    _Scheduler_default_Tick,              /* tick entry point */ \
     
    7978 */
    8079typedef struct {
     80  /**
     81   * @brief The thread priority currently used by the scheduler.
     82   */
     83  unsigned int current_priority;
     84
    8185  /** This field points to the Ready FIFO for this thread's priority. */
    8286  Chain_Control                        *ready_chain;
     
    135139
    136140/**
    137  *  @brief Updates the scheduler node to reflect the new priority of the
    138  *  thread.
    139  */
    140 void _Scheduler_priority_Update_priority(
    141   const Scheduler_Control *scheduler,
    142   Thread_Control          *the_thread,
    143   Priority_Control         new_priority
    144 );
    145 
    146 /**
    147141 *  @brief Add @a the_thread to the scheduling decision.
    148142 *
     
    159153);
    160154
    161 Scheduler_Void_or_thread _Scheduler_priority_Change_priority(
     155Scheduler_Void_or_thread _Scheduler_priority_Update_priority(
     156  const Scheduler_Control *scheduler,
     157  Thread_Control          *the_thread
     158);
     159
     160void _Scheduler_priority_Node_initialize(
    162161  const Scheduler_Control *scheduler,
    163162  Thread_Control          *the_thread,
    164   Priority_Control         new_priority,
    165   bool                     prepend_it
     163  Priority_Control         priority
    166164);
    167165
  • cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h

    r69a6802b r9bfad8c  
    5555    _Scheduler_priority_affinity_SMP_Block, \
    5656    _Scheduler_priority_affinity_SMP_Unblock, \
    57     _Scheduler_priority_affinity_SMP_Change_priority, \
     57    _Scheduler_priority_affinity_SMP_Update_priority, \
    5858    _Scheduler_default_Map_priority, \
    5959    _Scheduler_default_Unmap_priority, \
     
    6161    _Scheduler_priority_affinity_SMP_Node_initialize, \
    6262    _Scheduler_default_Node_destroy, \
    63     _Scheduler_priority_SMP_Update_priority, \
    6463    _Scheduler_default_Release_job, \
    6564    _Scheduler_default_Tick, \
     
    7776 *  @param[in] thread is the thread the scheduler is allocating
    7877 *             management memory for.
     78 *  @param[in] priority is the thread priority.
    7979 */
    8080void _Scheduler_priority_affinity_SMP_Node_initialize(
    8181  const Scheduler_Control *scheduler,
    82   Thread_Control          *thread
     82  Thread_Control          *the_thread,
     83  Priority_Control         priority
    8384);
    8485
     
    128129
    129130/**
    130  * @brief Change priority for the priority affinity SMP scheduler.
     131 * @brief Update priority for the priority affinity SMP scheduler.
    131132 *
    132133 * @param[in] scheduler The scheduler of the thread.
    133134 * @param[in] the_thread The associated thread.
    134  * @param[in] new_priority The new priority for the thread.
    135  * @param[in] prepend_it Append or prepend the thread to its priority FIFO.
    136135 */
    137 Thread_Control *_Scheduler_priority_affinity_SMP_Change_priority(
     136Thread_Control *_Scheduler_priority_affinity_SMP_Update_priority(
    138137  const Scheduler_Control *scheduler,
    139   Thread_Control          *the_thread,
    140   Priority_Control         new_priority,
    141   bool                     prepend_it
     138  Thread_Control          *the_thread
    142139);
    143140
  • cpukit/score/include/rtems/score/schedulerpriorityimpl.h

    r69a6802b r9bfad8c  
    211211)
    212212{
     213  ready_queue->current_priority = new_priority;
    213214  ready_queue->ready_chain = &ready_queues[ new_priority ];
    214215
  • cpukit/score/include/rtems/score/schedulerprioritysmp.h

    r69a6802b r9bfad8c  
    8484    _Scheduler_priority_SMP_Block, \
    8585    _Scheduler_priority_SMP_Unblock, \
    86     _Scheduler_priority_SMP_Change_priority, \
     86    _Scheduler_priority_SMP_Update_priority, \
    8787    _Scheduler_default_Map_priority, \
    8888    _Scheduler_default_Unmap_priority, \
     
    9090    _Scheduler_priority_SMP_Node_initialize, \
    9191    _Scheduler_default_Node_destroy, \
    92     _Scheduler_priority_SMP_Update_priority, \
    9392    _Scheduler_default_Release_job, \
    9493    _Scheduler_default_Tick, \
     
    101100void _Scheduler_priority_SMP_Node_initialize(
    102101  const Scheduler_Control *scheduler,
    103   Thread_Control *thread
     102  Thread_Control          *the_thread,
     103  Priority_Control         priority
    104104);
    105105
     
    114114);
    115115
    116 Thread_Control *_Scheduler_priority_SMP_Change_priority(
     116Thread_Control *_Scheduler_priority_SMP_Update_priority(
    117117  const Scheduler_Control *scheduler,
    118   Thread_Control          *the_thread,
    119   Priority_Control         new_priority,
    120   bool                     prepend_it
     118  Thread_Control          *the_thread
    121119);
    122120
     
    125123  Thread_Control          *needs_help,
    126124  Thread_Control          *offers_help
    127 );
    128 
    129 void _Scheduler_priority_SMP_Update_priority(
    130   const Scheduler_Control *scheduler,
    131   Thread_Control *thread,
    132   Priority_Control new_priority
    133125);
    134126
  • cpukit/score/include/rtems/score/schedulersimple.h

    r69a6802b r9bfad8c  
    4545    _Scheduler_simple_Block,              /* block entry point */ \
    4646    _Scheduler_simple_Unblock,            /* unblock entry point */ \
    47     _Scheduler_simple_Change_priority,    /* change priority entry point */ \
     47    _Scheduler_simple_Update_priority,    /* update priority entry point */ \
    4848    _Scheduler_default_Map_priority,      /* map priority entry point */ \
    4949    _Scheduler_default_Unmap_priority,    /* unmap priority entry point */ \
     
    5151    _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
    5252    _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
    53     _Scheduler_default_Update_priority,   /* update priority entry point */ \
    5453    _Scheduler_default_Release_job,       /* new period of task */ \
    5554    _Scheduler_default_Tick,              /* tick entry point */ \
     
    146145);
    147146
    148 Scheduler_Void_or_thread _Scheduler_simple_Change_priority(
     147Scheduler_Void_or_thread _Scheduler_simple_Update_priority(
    149148  const Scheduler_Control *scheduler,
    150   Thread_Control          *the_thread,
    151   Priority_Control         new_priority,
    152   bool                     prepend_it
     149  Thread_Control          *the_thread
    153150);
    154151
  • cpukit/score/include/rtems/score/schedulersimplesmp.h

    r69a6802b r9bfad8c  
    6767    _Scheduler_simple_SMP_Block, \
    6868    _Scheduler_simple_SMP_Unblock, \
    69     _Scheduler_simple_SMP_Change_priority, \
     69    _Scheduler_simple_SMP_Update_priority, \
    7070    _Scheduler_default_Map_priority, \
    7171    _Scheduler_default_Unmap_priority, \
     
    7373    _Scheduler_simple_SMP_Node_initialize, \
    7474    _Scheduler_default_Node_destroy, \
    75     _Scheduler_simple_SMP_Update_priority, \
    7675    _Scheduler_default_Release_job, \
    7776    _Scheduler_default_Tick, \
     
    8483void _Scheduler_simple_SMP_Node_initialize(
    8584  const Scheduler_Control *scheduler,
    86   Thread_Control          *the_thread
     85  Thread_Control          *the_thread,
     86  Priority_Control         priority
    8787);
    8888
     
    9797);
    9898
    99 Thread_Control *_Scheduler_simple_SMP_Change_priority(
     99Thread_Control *_Scheduler_simple_SMP_Update_priority(
    100100  const Scheduler_Control *scheduler,
    101   Thread_Control          *the_thread,
    102   Priority_Control         new_priority,
    103   bool                     prepend_it
     101  Thread_Control          *the_thread
    104102);
    105103
     
    108106  Thread_Control          *offers_help,
    109107  Thread_Control          *needs_help
    110 );
    111 
    112 void _Scheduler_simple_SMP_Update_priority(
    113   const Scheduler_Control *scheduler,
    114   Thread_Control          *thread,
    115   Priority_Control         new_priority
    116108);
    117109
  • cpukit/score/include/rtems/score/schedulersmpimpl.h

    r69a6802b r9bfad8c  
    388388static inline void _Scheduler_SMP_Node_initialize(
    389389  Scheduler_SMP_Node *node,
    390   Thread_Control     *thread
    391 )
    392 {
    393   _Scheduler_Node_do_initialize( &node->Base, thread );
     390  Thread_Control     *thread,
     391  Priority_Control    priority
     392)
     393{
     394  _Scheduler_Node_do_initialize( &node->Base, thread, priority );
    394395  node->state = SCHEDULER_SMP_NODE_BLOCKED;
     396  node->priority = priority;
    395397}
    396398
     
    890892
    891893static inline Thread_Control *_Scheduler_SMP_Unblock(
    892   Scheduler_Context             *context,
    893   Thread_Control                *thread,
    894   Scheduler_SMP_Enqueue          enqueue_fifo
    895 )
    896 {
    897   Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_node( thread );
    898   bool is_scheduled = node->state == SCHEDULER_SMP_NODE_SCHEDULED;
    899   bool unblock = _Scheduler_Unblock_node(
     894  Scheduler_Context     *context,
     895  Thread_Control        *thread,
     896  Scheduler_SMP_Update   update,
     897  Scheduler_SMP_Enqueue  enqueue_fifo
     898)
     899{
     900  Scheduler_SMP_Node *node;
     901  bool                is_scheduled;
     902  bool                unblock;
     903  Thread_Control     *needs_help;
     904
     905  node = _Scheduler_SMP_Thread_get_node( thread );
     906  is_scheduled = ( node->state == SCHEDULER_SMP_NODE_SCHEDULED );
     907  unblock = _Scheduler_Unblock_node(
    900908    context,
    901909    thread,
     
    904912    _Scheduler_SMP_Release_idle_thread
    905913  );
    906   Thread_Control *needs_help;
    907914
    908915  if ( unblock ) {
     916    Priority_Control new_priority;
     917    bool             prepend_it;
     918
     919    new_priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     920    (void) prepend_it;
     921
     922    if ( new_priority != node->priority ) {
     923      ( *update )( context, &node->Base, new_priority );
     924    }
     925
    909926    if ( node->state == SCHEDULER_SMP_NODE_BLOCKED ) {
    910927      _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY );
     
    932949}
    933950
    934 static inline Thread_Control *_Scheduler_SMP_Change_priority(
     951static inline Thread_Control *_Scheduler_SMP_Update_priority(
    935952  Scheduler_Context               *context,
    936953  Thread_Control                  *thread,
    937   Priority_Control                 new_priority,
    938   bool                             prepend_it,
    939954  Scheduler_SMP_Extract            extract_from_ready,
    940955  Scheduler_SMP_Update             update,
     
    945960)
    946961{
    947   Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( thread );
    948   Thread_Control *needs_help;
     962  Scheduler_SMP_Node *node;
     963  Thread_Control     *needs_help;
     964  Priority_Control    new_priority;
     965  bool                prepend_it;
     966
     967  node = _Scheduler_SMP_Thread_get_own_node( thread );
     968  new_priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     969
     970  if ( new_priority == node->priority ) {
     971    /* Nothing to do */
     972    return NULL;
     973  }
    949974
    950975  if ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ) {
  • cpukit/score/include/rtems/score/schedulerstrongapa.h

    r69a6802b r9bfad8c  
    8484    _Scheduler_strong_APA_Block, \
    8585    _Scheduler_strong_APA_Unblock, \
    86     _Scheduler_strong_APA_Change_priority, \
     86    _Scheduler_strong_APA_Update_priority, \
    8787    _Scheduler_default_Map_priority, \
    8888    _Scheduler_default_Unmap_priority, \
     
    9090    _Scheduler_strong_APA_Node_initialize, \
    9191    _Scheduler_default_Node_destroy, \
    92     _Scheduler_strong_APA_Update_priority, \
    9392    _Scheduler_default_Release_job, \
    9493    _Scheduler_default_Tick, \
     
    101100void _Scheduler_strong_APA_Node_initialize(
    102101  const Scheduler_Control *scheduler,
    103   Thread_Control          *the_thread
     102  Thread_Control          *the_thread,
     103  Priority_Control         priority
    104104);
    105105
     
    114114);
    115115
    116 Thread_Control *_Scheduler_strong_APA_Change_priority(
     116Thread_Control *_Scheduler_strong_APA_Update_priority(
    117117  const Scheduler_Control *scheduler,
    118   Thread_Control          *the_thread,
    119   Priority_Control         new_priority,
    120   bool                     prepend_it
     118  Thread_Control          *the_thread
    121119);
    122120
     
    125123  Thread_Control          *needs_help,
    126124  Thread_Control          *offers_help
    127 );
    128 
    129 void _Scheduler_strong_APA_Update_priority(
    130   const Scheduler_Control *scheduler,
    131   Thread_Control          *the_thread,
    132   Priority_Control         new_priority
    133125);
    134126
  • cpukit/score/include/rtems/score/thread.h

    r69a6802b r9bfad8c  
    364364
    365365  /**
    366    * @brief Generation of the current priority value.
    367    *
    368    * It is used in _Thread_Change_priority() to serialize the update of
    369    * priority related data structures.
    370    */
    371   uint32_t                 priority_generation;
    372 
    373   /**
    374366   * @brief Hints if a priority restore is necessary once the resource count
    375367   * changes from one to zero.
     
    743735   */
    744736  Priority_Control         real_priority;
    745 
    746   /**
    747    * @brief Generation of the current priority value.
    748    *
    749    * It is used in _Thread_Change_priority() to serialize the update of
    750    * priority related data structures.
    751    */
    752   uint32_t                 priority_generation;
    753737
    754738  /**
  • cpukit/score/include/rtems/score/threadimpl.h

    r69a6802b r9bfad8c  
    254254void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing );
    255255
     256RTEMS_INLINE_ROUTINE bool _Thread_Is_ready( const Thread_Control *the_thread )
     257{
     258  return _States_Is_ready( the_thread->current_state );
     259}
     260
    256261States_Control _Thread_Clear_state_locked(
    257262  Thread_Control *the_thread,
  • cpukit/score/src/schedulercbsnodeinit.c

    r69a6802b r9bfad8c  
    2323void _Scheduler_CBS_Node_initialize(
    2424  const Scheduler_Control *scheduler,
    25   Thread_Control          *the_thread
     25  Thread_Control          *the_thread,
     26  Priority_Control         priority
    2627)
    2728{
    2829  Scheduler_CBS_Node *node;
    2930
    30   _Scheduler_EDF_Node_initialize( scheduler, the_thread );
     31  _Scheduler_EDF_Node_initialize( scheduler, the_thread, priority );
    3132
    3233  node = _Scheduler_CBS_Thread_get_node( the_thread );
  • cpukit/score/src/schedulercbsunblock.c

    r69a6802b r9bfad8c  
    3535  Scheduler_CBS_Server  *serv_info;
    3636  Priority_Control       priority;
     37  bool                   prepend_it;
    3738
    3839  context = _Scheduler_EDF_Get_context( scheduler );
    3940  node = _Scheduler_CBS_Thread_get_node( the_thread );
    4041  serv_info = node->cbs_server;
    41   priority = node->Base.current_priority;
     42  priority = _Scheduler_Node_get_priority( &node->Base.Base, &prepend_it );
     43  (void) prepend_it;
    4244
    4345  /*
  • cpukit/score/src/schedulerdefaultnodeinit.c

    r69a6802b r9bfad8c  
    2424void _Scheduler_default_Node_initialize(
    2525  const Scheduler_Control *scheduler,
    26   Thread_Control          *the_thread
     26  Thread_Control          *the_thread,
     27  Priority_Control         priority
    2728)
    2829{
     
    3132  (void) scheduler;
    3233
    33   _Scheduler_Node_do_initialize( node, the_thread );
     34  _Scheduler_Node_do_initialize( node, the_thread, priority );
    3435}
  • cpukit/score/src/scheduleredfchangepriority.c

    r69a6802b r9bfad8c  
    3737}
    3838
    39 Scheduler_Void_or_thread _Scheduler_EDF_Change_priority(
     39Scheduler_Void_or_thread _Scheduler_EDF_Update_priority(
    4040  const Scheduler_Control *scheduler,
    41   Thread_Control          *the_thread,
    42   Priority_Control         new_priority,
    43   bool                     prepend_it
     41  Thread_Control          *the_thread
    4442)
    4543{
    4644  Scheduler_EDF_Context *context;
    4745  Scheduler_EDF_Node    *node;
     46  Priority_Control       priority;
     47  bool                   prepend_it;
    4848
    49   context = _Scheduler_EDF_Get_context( scheduler );
    50   node = _Scheduler_EDF_Thread_get_node( the_thread );
    51 
    52   if ( ( new_priority & SCHEDULER_EDF_PRIO_MSB ) != 0 ) {
    53     node->background_priority = new_priority;
     49  if ( !_Thread_Is_ready( the_thread ) ) {
     50    /* Nothing to do */
     51    SCHEDULER_RETURN_VOID_OR_NULL;
    5452  }
    5553
    56   node->current_priority = new_priority;
     54  node = _Scheduler_EDF_Thread_get_node( the_thread );
     55  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     56
     57  if ( priority == node->current_priority ) {
     58    /* Nothing to do */
     59    SCHEDULER_RETURN_VOID_OR_NULL;
     60  }
     61
     62  if ( ( priority & SCHEDULER_EDF_PRIO_MSB ) != 0 ) {
     63    node->background_priority = priority;
     64  }
     65
     66  node->current_priority = priority;
     67  context = _Scheduler_EDF_Get_context( scheduler );
    5768
    5869  _Scheduler_EDF_Extract( context, node );
    5970
    6071  if ( prepend_it ) {
    61     _Scheduler_EDF_Enqueue_first( context, node, new_priority );
     72    _Scheduler_EDF_Enqueue_first( context, node, priority );
    6273  } else {
    63     _Scheduler_EDF_Enqueue( context, node, new_priority );
     74    _Scheduler_EDF_Enqueue( context, node, priority );
    6475  }
    6576
  • cpukit/score/src/scheduleredfnodeinit.c

    r69a6802b r9bfad8c  
    2323void _Scheduler_EDF_Node_initialize(
    2424  const Scheduler_Control *scheduler,
    25   Thread_Control          *the_thread
     25  Thread_Control          *the_thread,
     26  Priority_Control         priority
    2627)
    2728{
     
    3031  (void) scheduler;
    3132
    32   _Scheduler_Node_do_initialize( &node->Base, the_thread );
     33  _Scheduler_Node_do_initialize( &node->Base, the_thread, priority );
    3334
    3435  node->thread = the_thread;
  • cpukit/score/src/scheduleredfunblock.c

    r69a6802b r9bfad8c  
    3030  Scheduler_EDF_Context *context;
    3131  Scheduler_EDF_Node    *node;
     32  Priority_Control       priority;
     33  bool                   prepend_it;
    3234
    3335  context = _Scheduler_EDF_Get_context( scheduler );
    3436  node = _Scheduler_EDF_Thread_get_node( the_thread );
     37  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     38  (void) prepend_it;
    3539
    36   _Scheduler_EDF_Enqueue( context, node, node->current_priority );
     40  node->current_priority = priority;
     41  _Scheduler_EDF_Enqueue( context, node, priority );
    3742
    3843  /*
     
    4853   *    a pseudo-ISR system task, we need to do a context switch.
    4954   */
    50   if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
    51     _Scheduler_Update_heir(
    52       the_thread,
    53       the_thread->current_priority == PRIORITY_PSEUDO_ISR
    54     );
     55  if ( priority < _Thread_Heir->current_priority ) {
     56    _Scheduler_Update_heir( the_thread, priority == PRIORITY_PSEUDO_ISR );
    5557  }
    5658
  • cpukit/score/src/schedulerpriority.c

    r69a6802b r9bfad8c  
    3333  );
    3434}
     35
     36void _Scheduler_priority_Node_initialize(
     37  const Scheduler_Control *scheduler,
     38  Thread_Control          *the_thread,
     39  Priority_Control         priority
     40)
     41{
     42  Scheduler_priority_Context *context;
     43  Scheduler_priority_Node    *node;
     44
     45  context = _Scheduler_priority_Get_context( scheduler );
     46  node = _Scheduler_priority_Thread_get_node( the_thread );
     47
     48  _Scheduler_Node_do_initialize( &node->Base, the_thread, priority );
     49  _Scheduler_priority_Ready_queue_update(
     50    &node->Ready_queue,
     51    priority,
     52    &context->Bit_map,
     53    &context->Ready[ 0 ]
     54  );
     55}
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r69a6802b r9bfad8c  
    9797void _Scheduler_priority_affinity_SMP_Node_initialize(
    9898  const Scheduler_Control *scheduler,
    99   Thread_Control          *thread
     99  Thread_Control          *the_thread,
     100  Priority_Control         priority
    100101)
    101102{
    102103  Scheduler_priority_affinity_SMP_Node *node =
    103     _Scheduler_priority_affinity_SMP_Thread_get_own_node( thread );
    104 
    105   (void) scheduler;
    106 
    107   _Scheduler_SMP_Node_initialize( &node->Base.Base, thread );
     104    _Scheduler_priority_affinity_SMP_Thread_get_own_node( the_thread );
     105
     106  _Scheduler_priority_SMP_Node_initialize( scheduler, the_thread, priority );
    108107
    109108  /*
     
    410409    context,
    411410    thread,
     411    _Scheduler_priority_SMP_Do_update,
    412412    _Scheduler_priority_affinity_SMP_Enqueue_fifo
    413413  );
     
    536536 * This is the public scheduler specific Change Priority operation.
    537537 */
    538 Thread_Control *_Scheduler_priority_affinity_SMP_Change_priority(
     538Thread_Control *_Scheduler_priority_affinity_SMP_Update_priority(
    539539  const Scheduler_Control *scheduler,
    540   Thread_Control          *thread,
    541   Priority_Control         new_priority,
    542   bool                     prepend_it
     540  Thread_Control          *thread
    543541)
    544542{
     
    546544  Thread_Control    *displaced;
    547545
    548   displaced = _Scheduler_SMP_Change_priority(
     546  displaced = _Scheduler_SMP_Update_priority(
    549547    context,
    550548    thread,
    551     new_priority,
    552     prepend_it,
    553549    _Scheduler_priority_SMP_Extract_from_ready,
    554550    _Scheduler_priority_SMP_Do_update,
  • cpukit/score/src/schedulerprioritychangepriority.c

    r69a6802b r9bfad8c  
    2222#include <rtems/score/schedulerpriorityimpl.h>
    2323
    24 Scheduler_Void_or_thread _Scheduler_priority_Change_priority(
     24Scheduler_Void_or_thread _Scheduler_priority_Update_priority(
    2525  const Scheduler_Control *scheduler,
    26   Thread_Control          *the_thread,
    27   Priority_Control         new_priority,
    28   bool                     prepend_it
     26  Thread_Control          *the_thread
    2927)
    3028{
    31   Scheduler_priority_Context *context =
    32     _Scheduler_priority_Get_context( scheduler );
    33   Scheduler_priority_Node *node = _Scheduler_priority_Thread_get_node( the_thread );
     29  Scheduler_priority_Context *context;
     30  Scheduler_priority_Node    *node;
     31  unsigned int                priority;
     32  bool                        prepend_it;
     33
     34  if ( !_Thread_Is_ready( the_thread ) ) {
     35    /* Nothing to do */
     36    SCHEDULER_RETURN_VOID_OR_NULL;
     37  }
     38
     39  node = _Scheduler_priority_Thread_get_node( the_thread );
     40  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     41
     42  if ( priority == node->Ready_queue.current_priority ) {
     43    /* Nothing to do */
     44    SCHEDULER_RETURN_VOID_OR_NULL;
     45  }
     46
     47  context = _Scheduler_priority_Get_context( scheduler );
    3448
    3549  _Scheduler_priority_Ready_queue_extract(
     
    4155  _Scheduler_priority_Ready_queue_update(
    4256    &node->Ready_queue,
    43     new_priority,
     57    priority,
    4458    &context->Bit_map,
    4559    &context->Ready[ 0 ]
  • cpukit/score/src/schedulerprioritysmp.c

    r69a6802b r9bfad8c  
    4848void _Scheduler_priority_SMP_Node_initialize(
    4949  const Scheduler_Control *scheduler,
    50   Thread_Control *thread
    51 )
    52 {
    53   Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( thread );
    54 
    55   _Scheduler_SMP_Node_initialize( node, thread );
    56 }
    57 
    58 void _Scheduler_priority_SMP_Update_priority(
    59   const Scheduler_Control *scheduler,
    60   Thread_Control *thread,
    61   Priority_Control new_priority
    62 )
    63 {
    64   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    65   Scheduler_Node *node = _Scheduler_Thread_get_node( thread );
    66 
    67   _Scheduler_priority_SMP_Do_update( context, node, new_priority );
     50  Thread_Control          *the_thread,
     51  Priority_Control         priority
     52)
     53{
     54  Scheduler_Context              *context;
     55  Scheduler_priority_SMP_Context *self;
     56  Scheduler_priority_SMP_Node    *node;
     57
     58  context = _Scheduler_Get_context( scheduler );
     59  self = _Scheduler_priority_SMP_Get_self( context );
     60  node = _Scheduler_priority_SMP_Node_downcast(
     61    _Scheduler_Thread_get_own_node( the_thread )
     62  );
     63
     64  _Scheduler_SMP_Node_initialize( &node->Base, the_thread, priority );
     65  _Scheduler_priority_Ready_queue_update(
     66    &node->Ready_queue,
     67    priority,
     68    &self->Bit_map,
     69    &self->Ready[ 0 ]
     70  );
    6871}
    6972
     
    214217    context,
    215218    thread,
     219    _Scheduler_priority_SMP_Do_update,
    216220    _Scheduler_priority_SMP_Enqueue_fifo
    217221  );
    218222}
    219223
    220 Thread_Control *_Scheduler_priority_SMP_Change_priority(
    221   const Scheduler_Control *scheduler,
    222   Thread_Control          *thread,
    223   Priority_Control         new_priority,
    224   bool                     prepend_it
    225 )
    226 {
    227   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    228 
    229   return _Scheduler_SMP_Change_priority(
    230     context,
    231     thread,
    232     new_priority,
    233     prepend_it,
     224Thread_Control *_Scheduler_priority_SMP_Update_priority(
     225  const Scheduler_Control *scheduler,
     226  Thread_Control          *thread
     227)
     228{
     229  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     230
     231  return _Scheduler_SMP_Update_priority(
     232    context,
     233    thread,
    234234    _Scheduler_priority_SMP_Extract_from_ready,
    235235    _Scheduler_priority_SMP_Do_update,
  • cpukit/score/src/schedulerpriorityunblock.c

    r69a6802b r9bfad8c  
    2828)
    2929{
    30   Scheduler_priority_Context *context =
    31     _Scheduler_priority_Get_context( scheduler );
    32   Scheduler_priority_Node *node = _Scheduler_priority_Thread_get_node( the_thread );
     30  Scheduler_priority_Context *context;
     31  Scheduler_priority_Node    *node;
     32  unsigned int                priority;
     33  bool                        prepend_it;
     34
     35  context = _Scheduler_priority_Get_context( scheduler );
     36  node = _Scheduler_priority_Thread_get_node( the_thread );
     37  priority = _Scheduler_Node_get_priority( &node->Base, &prepend_it );
     38  (void) prepend_it;
     39
     40  if ( priority != node->Ready_queue.current_priority ) {
     41    _Scheduler_priority_Ready_queue_update(
     42      &node->Ready_queue,
     43      priority,
     44      &context->Bit_map,
     45      &context->Ready[ 0 ]
     46    );
     47  }
    3348
    3449  _Scheduler_priority_Ready_queue_enqueue(
     
    5267   *    a pseudo-ISR system task, we need to do a context switch.
    5368   */
    54   if ( the_thread->current_priority < _Thread_Heir->current_priority ) {
    55     _Scheduler_Update_heir(
    56       the_thread,
    57       the_thread->current_priority == PRIORITY_PSEUDO_ISR
    58     );
     69  if ( priority < _Thread_Heir->current_priority ) {
     70    _Scheduler_Update_heir( the_thread, priority == PRIORITY_PSEUDO_ISR );
    5971  }
    6072
  • cpukit/score/src/schedulersimplechangepriority.c

    r69a6802b r9bfad8c  
    2222#include <rtems/score/schedulersimpleimpl.h>
    2323
    24 Scheduler_Void_or_thread _Scheduler_simple_Change_priority(
     24Scheduler_Void_or_thread _Scheduler_simple_Update_priority(
    2525  const Scheduler_Control *scheduler,
    26   Thread_Control          *the_thread,
    27   Priority_Control         new_priority,
    28   bool                     prepend_it
     26  Thread_Control          *the_thread
    2927)
    3028{
    31   Scheduler_simple_Context *context =
    32     _Scheduler_simple_Get_context( scheduler );
     29  Scheduler_simple_Context *context;
     30  Scheduler_Node           *node;
     31  bool                      prepend_it;
     32
     33  if ( !_Thread_Is_ready( the_thread ) ) {
     34    /* Nothing to do */
     35    SCHEDULER_RETURN_VOID_OR_NULL;
     36  }
     37
     38  context = _Scheduler_simple_Get_context( scheduler );
     39  node = _Scheduler_Thread_get_node( the_thread );
     40  _Scheduler_Node_get_priority( node, &prepend_it );
    3341
    3442  _Scheduler_simple_Extract( scheduler, the_thread );
  • cpukit/score/src/schedulersimplesmp.c

    r69a6802b r9bfad8c  
    4545void _Scheduler_simple_SMP_Node_initialize(
    4646  const Scheduler_Control *scheduler,
    47   Thread_Control          *the_thread
     47  Thread_Control          *the_thread,
     48  Priority_Control         priority
    4849)
    4950{
    5051  Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( the_thread );
    5152
    52   _Scheduler_SMP_Node_initialize( node, the_thread );
     53  _Scheduler_SMP_Node_initialize( node, the_thread, priority );
    5354}
    5455
     
    6465
    6566  _Scheduler_SMP_Node_update_priority( node, new_priority );
    66 }
    67 
    68 void _Scheduler_simple_SMP_Update_priority(
    69   const Scheduler_Control *scheduler,
    70   Thread_Control          *thread,
    71   Priority_Control         new_priority
    72 )
    73 {
    74   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    75   Scheduler_Node *node = _Scheduler_Thread_get_node( thread );
    76 
    77   _Scheduler_simple_SMP_Do_update( context, node, new_priority );
    7867}
    7968
     
    296285    context,
    297286    thread,
     287    _Scheduler_simple_SMP_Do_update,
    298288    _Scheduler_simple_SMP_Enqueue_fifo
    299289  );
    300290}
    301291
    302 Thread_Control *_Scheduler_simple_SMP_Change_priority(
    303   const Scheduler_Control *scheduler,
    304   Thread_Control          *thread,
    305   Priority_Control         new_priority,
    306   bool                     prepend_it
    307 )
    308 {
    309   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    310 
    311   return _Scheduler_SMP_Change_priority(
     292Thread_Control *_Scheduler_simple_SMP_Update_priority(
     293  const Scheduler_Control *scheduler,
     294  Thread_Control          *thread
     295)
     296{
     297  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     298
     299  return _Scheduler_SMP_Update_priority(
    312300    context,
    313301    thread,
    314     new_priority,
    315     prepend_it,
    316302    _Scheduler_simple_SMP_Extract_from_ready,
    317303    _Scheduler_simple_SMP_Do_update,
  • cpukit/score/src/schedulerstrongapa.c

    r69a6802b r9bfad8c  
    174174void _Scheduler_strong_APA_Node_initialize(
    175175  const Scheduler_Control *scheduler,
    176   Thread_Control          *the_thread
    177 )
    178 {
    179   Scheduler_SMP_Node *node = _Scheduler_SMP_Thread_get_own_node( the_thread );
    180 
    181   _Scheduler_SMP_Node_initialize( node, the_thread );
    182 }
    183 
    184 void _Scheduler_strong_APA_Update_priority(
    185   const Scheduler_Control *scheduler,
    186176  Thread_Control          *the_thread,
    187   Priority_Control         new_priority
    188 )
    189 {
    190   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    191   Scheduler_Node *node = _Scheduler_Thread_get_node( the_thread );
    192 
    193   _Scheduler_strong_APA_Do_update( context, node, new_priority );
     177  Priority_Control         priority
     178)
     179{
     180  Scheduler_Context            *context;
     181  Scheduler_strong_APA_Context *self;
     182  Scheduler_strong_APA_Node    *node;
     183
     184  context = _Scheduler_Get_context( scheduler );
     185  self = _Scheduler_strong_APA_Get_self( context );
     186  node = _Scheduler_strong_APA_Node_downcast(
     187    _Scheduler_Thread_get_own_node( the_thread )
     188  );
     189
     190  _Scheduler_SMP_Node_initialize( &node->Base, the_thread, priority );
     191  _Scheduler_priority_Ready_queue_update(
     192    &node->Ready_queue,
     193    priority,
     194    &self->Bit_map,
     195    &self->Ready[ 0 ]
     196  );
    194197}
    195198
     
    340343    context,
    341344    the_thread,
     345    _Scheduler_strong_APA_Do_update,
    342346    _Scheduler_strong_APA_Enqueue_fifo
    343347  );
    344348}
    345349
    346 Thread_Control *_Scheduler_strong_APA_Change_priority(
    347   const Scheduler_Control *scheduler,
    348   Thread_Control          *the_thread,
    349   Priority_Control         new_priority,
    350   bool                     prepend_it
    351 )
    352 {
    353   Scheduler_Context *context = _Scheduler_Get_context( scheduler );
    354 
    355   return _Scheduler_SMP_Change_priority(
     350Thread_Control *_Scheduler_strong_APA_Update_priority(
     351  const Scheduler_Control *scheduler,
     352  Thread_Control          *the_thread
     353)
     354{
     355  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     356
     357  return _Scheduler_SMP_Update_priority(
    356358    context,
    357359    the_thread,
    358     new_priority,
    359     prepend_it,
    360360    _Scheduler_strong_APA_Extract_from_ready,
    361361    _Scheduler_strong_APA_Do_update,
  • cpukit/score/src/thread.c

    r69a6802b r9bfad8c  
    3535THREAD_OFFSET_ASSERT( current_priority );
    3636THREAD_OFFSET_ASSERT( real_priority );
    37 THREAD_OFFSET_ASSERT( priority_generation );
    3837THREAD_OFFSET_ASSERT( priority_restore_hint );
    3938THREAD_OFFSET_ASSERT( resource_count );
  • cpukit/score/src/threadchangepriority.c

    r69a6802b r9bfad8c  
    5151   */
    5252  if ( ( *filter )( the_thread, &new_priority, arg ) ) {
    53     uint32_t my_generation;
     53    Scheduler_Node *own_node;
    5454
    55     my_generation = the_thread->priority_generation + 1;
     55    own_node = _Scheduler_Thread_get_own_node( the_thread );
     56    _Scheduler_Node_set_priority( own_node, new_priority, prepend_it );
     57
    5658    the_thread->current_priority = new_priority;
    57     the_thread->priority_generation = my_generation;
    5859
    5960    ( *the_thread->Wait.operations->priority_change )(
     
    6667
    6768    _Thread_State_acquire( the_thread, &lock_context );
    68 
    69     if ( the_thread->priority_generation == my_generation ) {
    70       if ( _States_Is_ready( the_thread->current_state ) ) {
    71         _Scheduler_Change_priority(
    72           the_thread,
    73           new_priority,
    74           prepend_it
    75         );
    76       } else {
    77         _Scheduler_Update_priority( the_thread, new_priority );
    78       }
    79     }
    80 
     69    _Scheduler_Update_priority( the_thread );
    8170    _Thread_State_release( the_thread, &lock_context );
    8271  } else {
  • cpukit/score/src/threadinitialize.c

    r69a6802b r9bfad8c  
    201201  RTEMS_STATIC_ASSERT( THREAD_WAIT_FLAGS_INITIAL == 0, Wait_flags );
    202202
    203   _Scheduler_Node_initialize( scheduler, the_thread );
     203  _Scheduler_Node_initialize( scheduler, the_thread, priority );
    204204  scheduler_node_initialized = true;
    205 
    206   _Scheduler_Update_priority( the_thread, priority );
    207205
    208206  /* POSIX Keys */
  • testsuites/smptests/smpscheduler03/init.c

    r69a6802b r9bfad8c  
    188188}
    189189
    190 static Thread_Control *change_priority_op(
     190static Thread_Control *update_priority_op(
    191191  Thread_Control *thread,
    192192  Priority_Control new_priority,
     
    198198  ISR_lock_Context scheduler_lock_context;
    199199  Thread_Control *needs_help;
     200  Scheduler_Node *node;
     201
     202  thread->current_priority = new_priority;
     203  node = _Scheduler_Thread_get_node(thread);
     204  _Scheduler_Node_set_priority(node, new_priority, prepend_it);
    200205
    201206  _Thread_State_acquire( thread, &state_lock_context );
     
    203208  _Scheduler_Acquire_critical( scheduler, &scheduler_lock_context );
    204209
    205   thread->current_priority = new_priority;
    206   needs_help = (*scheduler->Operations.change_priority)(
    207     scheduler,
    208     thread,
    209     new_priority,
    210     prepend_it
    211   );
     210  needs_help = (*scheduler->Operations.update_priority)( scheduler, thread);
    212211
    213212  _Scheduler_Release_critical( scheduler, &scheduler_lock_context );
     
    217216}
    218217
    219 static void test_case_change_priority_op(
     218static void test_case_update_priority_op(
    220219  Thread_Control *executing,
    221220  Scheduler_SMP_Node *executing_node,
     
    245244  rtems_test_assert(executing_node->state == start_state);
    246245
    247   needs_help = change_priority_op(executing, prio, prepend_it);
     246  needs_help = update_priority_op(executing, prio, prepend_it);
    248247  rtems_test_assert(executing_node->state == new_state);
    249248
     
    270269}
    271270
    272 static void test_change_priority_op(void)
     271static void test_update_priority_op(void)
    273272{
    274273  rtems_status_code sc;
     
    290289    for (j = 0; j < RTEMS_ARRAY_SIZE(priorities); ++j) {
    291290      for (k = 0; k < RTEMS_ARRAY_SIZE(prepend_it); ++k) {
    292         test_case_change_priority_op(
     291        test_case_update_priority_op(
    293292          executing,
    294293          executing_node,
     
    556555{
    557556  test_change_priority();
    558   test_change_priority_op();
     557  test_update_priority_op();
    559558  test_yield_op();
    560559  test_unblock_op();
  • testsuites/sptests/spintrcritical23/init.c

    r69a6802b r9bfad8c  
    11/*
    2  * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2015, 2016 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    2323
    2424#include <rtems.h>
    25 #include <rtems/score/schedulerpriority.h>
     25#include <rtems/score/schedulerpriorityimpl.h>
    2626#include <rtems/score/threadimpl.h>
    2727
     
    3131  RTEMS_INTERRUPT_LOCK_MEMBER(lock)
    3232  rtems_id task_id;
    33   Thread_Control *tcb;
     33  Scheduler_priority_Node *scheduler_node;
    3434  rtems_task_priority priority_task;
    3535  rtems_task_priority priority_interrupt;
    36   uint32_t priority_generation;
    37   Scheduler_priority_Node scheduler_node;
    3836  bool done;
    3937} test_context;
    4038
    4139static test_context ctx_instance;
    42 
    43 static Thread_Control *get_tcb(rtems_id id)
    44 {
    45   ISR_lock_Context lock_context;
    46   Thread_Control *tcb;
    47 
    48   tcb = _Thread_Get(id, &lock_context);
    49   rtems_test_assert(tcb != NULL);
    50   _ISR_lock_ISR_enable(&lock_context);
    51 
    52   return tcb;
    53 }
    54 
    55 static bool scheduler_node_unchanged(const test_context *ctx)
    56 {
    57    return memcmp(
    58      &ctx->scheduler_node,
    59      ctx->tcb->Scheduler.node,
    60      sizeof(ctx->scheduler_node)
    61    ) == 0;
    62 }
    6340
    6441static void change_priority(rtems_id timer, void *arg)
     
    7047  rtems_interrupt_lock_acquire(&ctx->lock, &lock_context);
    7148  if (
    72     ctx->priority_generation != ctx->tcb->priority_generation
    73       && scheduler_node_unchanged(ctx)
     49    ctx->scheduler_node->Ready_queue.current_priority
     50      != ctx->scheduler_node->Base.Priority.value
    7451  ) {
    7552    rtems_task_priority priority_interrupt;
     
    11390  ctx->priority_task = priority_task;
    11491  ctx->priority_interrupt = priority_interrupt;
    115   ctx->priority_generation = ctx->tcb->priority_generation;
    116   memcpy(
    117     &ctx->scheduler_node,
    118     ctx->tcb->Scheduler.node,
    119     sizeof(ctx->scheduler_node)
    120   );
    12192  rtems_interrupt_lock_release(&ctx->lock, &lock_context);
    12293
     
    145116{
    146117  test_context *ctx = &ctx_instance;
    147   rtems_status_code sc;
    148118
    149119  TEST_BEGIN();
     
    151121  rtems_interrupt_lock_initialize(&ctx->lock, "Test");
    152122  ctx->priority_task = 1;
    153 
    154   sc = rtems_task_create(
    155     rtems_build_name('T', 'E', 'S', 'T'),
    156     ctx->priority_task,
    157     RTEMS_MINIMUM_STACK_SIZE,
    158     RTEMS_DEFAULT_MODES,
    159     RTEMS_DEFAULT_ATTRIBUTES,
    160     &ctx->task_id
    161   );
    162   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    163 
    164   ctx->tcb = get_tcb(ctx->task_id);
     123  ctx->task_id = rtems_task_self();
     124  ctx->scheduler_node =
     125    _Scheduler_priority_Thread_get_node(_Thread_Get_executing());
    165126
    166127  interrupt_critical_section_test(test_body, ctx, change_priority);
     
    176137#define CONFIGURE_MICROSECONDS_PER_TICK 1000
    177138
    178 #define CONFIGURE_MAXIMUM_TASKS 2
     139#define CONFIGURE_MAXIMUM_TASKS 1
    179140#define CONFIGURE_MAXIMUM_TIMERS 1
    180141#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
Note: See TracChangeset for help on using the changeset viewer.