source: rtems/cpukit/score/src/schedulerprioritytick.c @ 6eba7c85

4.115
Last change on this file since 6eba7c85 was 6eba7c85, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 10, 2013 at 2:15:46 PM

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.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Priority Scheduler At Tick Handler
5 *
6 * @ingroup ScoreScheduler
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2009.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/schedulerpriority.h>
24
25void _Scheduler_priority_Tick( void )
26{
27  Thread_Control *executing;
28
29  executing = _Thread_Executing;
30
31  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
32    /*
33     *  Increment the number of ticks this thread has been executing
34     */
35    executing->cpu_time_used++;
36  #endif
37
38  /*
39   *  If the thread is not preemptible or is not ready, then
40   *  just return.
41   */
42
43  if ( !executing->is_preemptible )
44    return;
45
46  if ( !_States_Is_ready( executing->current_state ) )
47    return;
48
49  /*
50   *  The cpu budget algorithm determines what happens next.
51   */
52
53  switch ( executing->budget_algorithm ) {
54    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
55      break;
56
57    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
58    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
59      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
60    #endif
61      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
62
63        /*
64         *  A yield performs the ready chain mechanics needed when
65         *  resetting a timeslice.  If no other thread's are ready
66         *  at the priority of the currently executing thread, then the
67         *  executing thread's timeslice is reset.  Otherwise, the
68         *  currently executing thread is placed at the rear of the
69         *  FIFO for this priority and a new heir is selected.
70         */
71        _Scheduler_Yield( executing );
72        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
73      }
74      break;
75
76    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
77      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
78        if ( --executing->cpu_time_budget == 0 )
79          (*executing->budget_callout)( executing );
80        break;
81    #endif
82  }
83}
Note: See TracBrowser for help on using the repository browser.