Changeset 6eba7c85 in rtems


Ignore:
Timestamp:
Jun 10, 2013, 2:15:46 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
a344308
Parents:
1ccb64e1
git-author:
Sebastian Huber <sebastian.huber@…> (06/10/13 14:15:46)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/14/13 14:26:08)
Message:

scheduler: Specify thread of yield operation

The yielding thread of the yield operation is now specified by a
parameter. The tick operation may be performed for each executing
thread in a SMP configuration.

Location:
cpukit
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/nanosleep.c

    r1ccb64e1 r6eba7c85  
    4040)
    4141{
     42  /*
     43   * It is critical to obtain the executing thread after thread dispatching is
     44   * disabled on SMP configurations.
     45   */
     46  Thread_Control *executing;
     47
    4248  Watchdog_Interval  ticks;
    4349
     
    6268  if ( !ticks ) {
    6369    _Thread_Disable_dispatch();
    64       _Scheduler_Yield();
     70      executing = _Thread_Executing;
     71      _Scheduler_Yield( executing );
    6572    _Thread_Enable_dispatch();
    6673    if ( rmtp ) {
     
    7582   */
    7683  _Thread_Disable_dispatch();
     84    executing = _Thread_Executing;
    7785    _Thread_Set_state(
    78       _Thread_Executing,
     86      executing,
    7987      STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL
    8088    );
    8189    _Watchdog_Initialize(
    82       &_Thread_Executing->Timer,
     90      &executing->Timer,
    8391      _Thread_Delay_ended,
    84       _Thread_Executing->Object.id,
     92      executing->Object.id,
    8593      NULL
    8694    );
    87     _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks );
     95    _Watchdog_Insert_ticks( &executing->Timer, ticks );
    8896  _Thread_Enable_dispatch();
    8997
     
    9199
    92100  if ( rmtp ) {
    93     ticks -=
    94       _Thread_Executing->Timer.stop_time - _Thread_Executing->Timer.start_time;
     101    ticks -= executing->Timer.stop_time - executing->Timer.start_time;
    95102
    96103    _Timespec_From_ticks( ticks, rmtp );
  • cpukit/posix/src/sched_yield.c

    r1ccb64e1 r6eba7c85  
    3333{
    3434  _Thread_Disable_dispatch();
    35     _Scheduler_Yield();
     35    _Scheduler_Yield( _Thread_Executing );
    3636  _Thread_Enable_dispatch();
    3737  return 0;
  • cpukit/rtems/src/taskwakeafter.c

    r1ccb64e1 r6eba7c85  
    3939)
    4040{
     41  /*
     42   * It is critical to obtain the executing thread after thread dispatching is
     43   * disabled on SMP configurations.
     44   */
     45  Thread_Control *executing;
     46
    4147  _Thread_Disable_dispatch();
     48    executing = _Thread_Executing;
     49
    4250    if ( ticks == 0 ) {
    43       _Scheduler_Yield();
     51      _Scheduler_Yield( executing );
    4452    } else {
    45       _Thread_Set_state( _Thread_Executing, STATES_DELAYING );
     53      _Thread_Set_state( executing, STATES_DELAYING );
    4654      _Watchdog_Initialize(
    47         &_Thread_Executing->Timer,
     55        &executing->Timer,
    4856        _Thread_Delay_ended,
    49         _Thread_Executing->Object.id,
     57        executing->Object.id,
    5058        NULL
    5159      );
    52       _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks );
     60      _Watchdog_Insert_ticks( &executing->Timer, ticks );
    5361    }
    5462  _Thread_Enable_dispatch();
  • cpukit/score/include/rtems/score/scheduler.h

    r1ccb64e1 r6eba7c85  
    5050  void ( *schedule )(void);
    5151
    52   /** Voluntarily yields the processor per the scheduling policy. */
    53   void ( *yield )(void);
     52  /**
     53   * @brief Voluntarily yields the processor per the scheduling policy.
     54   *
     55   * @see _Scheduler_Yield().
     56   */
     57  void ( *yield )( Thread_Control *thread );
    5458
    5559  /** Removes the given thread from scheduling decisions. */
  • cpukit/score/include/rtems/score/scheduleredf.h

    r1ccb64e1 r6eba7c85  
    190190 *  equal deadline. This does not have to happen very often.
    191191 *
    192  *  This routine will remove the running THREAD from the ready queue
    193  *  and place back. The rbtree ready queue is responsible for FIFO ordering
     192 *  This routine will remove the specified THREAD from the ready queue
     193 *  and place it back. The rbtree ready queue is responsible for FIFO ordering
    194194 *  in such a case.
    195  */
    196 void _Scheduler_EDF_Yield( void );
     195 *
     196 *  @param[in/out] thread The yielding thread.
     197 */
     198void _Scheduler_EDF_Yield( Thread_Control *thread );
    197199
    198200/**
  • cpukit/score/include/rtems/score/schedulerpriority.h

    r1ccb64e1 r6eba7c85  
    146146
    147147/**
    148  *  @brief Remove the running THREAD to the rear of this chain.
     148 *  @brief The specified THREAD yields.
    149149 *
    150150 *  This routine is invoked when a thread wishes to voluntarily
    151151 *  transfer control of the processor to another thread in the queue.
    152152 *
    153  *  This routine will remove the running THREAD from the ready queue
     153 *  This routine will remove the specified THREAD from the ready queue
    154154 *  and place it immediately at the rear of this chain.  Reset timeslice
    155155 *  and yield the processor functions both use this routine, therefore if
     
    161161 *    + ready chain
    162162 *    + select heir
    163  */
    164 void _Scheduler_priority_Yield( void );
     163 *
     164 *  @param[in/out] thread The yielding thread.
     165 */
     166void _Scheduler_priority_Yield( Thread_Control *thread );
    165167
    166168/**
  • cpukit/score/include/rtems/score/schedulersimple.h

    r1ccb64e1 r6eba7c85  
    7575 *  This routine is invoked when a thread wishes to voluntarily
    7676 *  transfer control of the processor to another thread in the queue.
    77  *  It will remove the running THREAD from the scheduler.informaiton
     77 *  It will remove the specified THREAD from the scheduler.informaiton
    7878 *  (where the ready queue is stored) and place it immediately at the
    7979 *  between the last entry of its priority and the next priority thread.
     
    8282 *  the timeslice counter is reset.  The heir THREAD will be updated if the
    8383 *  running is also the currently the heir.
    84 */
    85 void _Scheduler_simple_Yield( void );
     84 *
     85 *  @param[in/out] thread The yielding thread.
     86 */
     87void _Scheduler_simple_Yield( Thread_Control *thread );
    8688
    8789/**
  • cpukit/score/inline/rtems/score/scheduler.inl

    r1ccb64e1 r6eba7c85  
    5656
    5757/**
    58  * @brief Scheduler yield.
    59  *
    60  * This routine is invoked when a thread wishes to voluntarily
    61  * transfer control of the processor to another thread. This routine
    62  * always operates on the scheduler that 'owns' the currently executing
    63  * thread.
    64  */
    65 RTEMS_INLINE_ROUTINE void _Scheduler_Yield( void )
    66 {
    67   _Scheduler.Operations.yield();
     58 * @brief Scheduler yield with a particular thread.
     59 *
     60 * This routine is invoked when a thread wishes to voluntarily transfer control
     61 * of the processor to another thread.
     62 *
     63 * @param[in] thread The yielding thread.
     64 */
     65RTEMS_INLINE_ROUTINE void _Scheduler_Yield(
     66  Thread_Control *thread
     67)
     68{
     69  ( *_Scheduler.Operations.yield )( thread );
    6870}
    6971
  • cpukit/score/src/scheduleredfyield.c

    r1ccb64e1 r6eba7c85  
    2626#include <rtems/score/thread.h>
    2727
    28 void _Scheduler_EDF_Yield(void)
     28void _Scheduler_EDF_Yield( Thread_Control *thread )
    2929{
    3030  ISR_Level                 level;
    3131
    32   Thread_Control *executing  = _Thread_Executing;
    33   Scheduler_EDF_Per_thread *executing_info =
    34     (Scheduler_EDF_Per_thread *) executing->scheduler_info;
    35   RBTree_Node *executing_node = &(executing_info->Node);
     32  Scheduler_EDF_Per_thread *thread_info =
     33    (Scheduler_EDF_Per_thread *) thread->scheduler_info;
     34  RBTree_Node *thread_node = &(thread_info->Node);
    3635
    3736  _ISR_Disable( level );
     
    4140   * with the same priority in case there are such ones.
    4241   */
    43   _RBTree_Extract( &_Scheduler_EDF_Ready_queue, executing_node );
    44   _RBTree_Insert( &_Scheduler_EDF_Ready_queue, executing_node );
     42  _RBTree_Extract( &_Scheduler_EDF_Ready_queue, thread_node );
     43  _RBTree_Insert( &_Scheduler_EDF_Ready_queue, thread_node );
    4544
    4645  _ISR_Flash( level );
  • cpukit/score/src/schedulerprioritytick.c

    r1ccb64e1 r6eba7c85  
    6969         *  FIFO for this priority and a new heir is selected.
    7070         */
    71         _Scheduler_Yield();
     71        _Scheduler_Yield( executing );
    7272        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
    7373      }
  • cpukit/score/src/schedulerpriorityyield.c

    r1ccb64e1 r6eba7c85  
    2525#include <rtems/score/thread.h>
    2626
    27 void _Scheduler_priority_Yield(void)
     27void _Scheduler_priority_Yield( Thread_Control *thread )
    2828{
    2929  Scheduler_priority_Per_thread *sched_info;
    3030  ISR_Level                      level;
    31   Thread_Control                *executing;
    3231  Chain_Control                 *ready;
    3332
    34   executing  = _Thread_Executing;
    35   sched_info = (Scheduler_priority_Per_thread *) executing->scheduler_info;
     33  sched_info = (Scheduler_priority_Per_thread *) thread->scheduler_info;
    3634  ready      = sched_info->ready_chain;
    3735  _ISR_Disable( level );
    3836    if ( !_Chain_Has_only_one_node( ready ) ) {
    39       _Chain_Extract_unprotected( &executing->Object.Node );
    40       _Chain_Append_unprotected( ready, &executing->Object.Node );
     37      _Chain_Extract_unprotected( &thread->Object.Node );
     38      _Chain_Append_unprotected( ready, &thread->Object.Node );
    4139
    4240      _ISR_Flash( level );
    4341
    44       if ( _Thread_Is_heir( executing ) )
     42      if ( _Thread_Is_heir( thread ) )
    4543        _Thread_Heir = (Thread_Control *) _Chain_First( ready );
    4644      _Thread_Dispatch_necessary = true;
    4745    }
    48     else if ( !_Thread_Is_heir( executing ) )
     46    else if ( !_Thread_Is_heir( thread ) )
    4947      _Thread_Dispatch_necessary = true;
    5048
  • cpukit/score/src/schedulersimpleyield.c

    r1ccb64e1 r6eba7c85  
    2525#include <rtems/score/schedulersimple.h>
    2626
    27 void _Scheduler_simple_Yield( void )
     27void _Scheduler_simple_Yield( Thread_Control *thread )
    2828{
    2929  ISR_Level       level;
    30   Thread_Control *executing;
    3130
    32   executing = _Thread_Executing;
    3331  _ISR_Disable( level );
    3432
    35     _Scheduler_simple_Ready_queue_requeue(&_Scheduler, executing);
     33    _Scheduler_simple_Ready_queue_requeue( &_Scheduler, thread );
    3634
    3735    _ISR_Flash( level );
     
    3937    _Scheduler_simple_Schedule();
    4038
    41     if ( !_Thread_Is_heir( executing ) )
     39    if ( !_Thread_Is_heir( thread ) )
    4240      _Thread_Dispatch_necessary = true;
    4341
Note: See TracChangeset for help on using the changeset viewer.