source: rtems/cpukit/score/src/schedulerdefaulttick.c @ a344308

4.115
Last change on this file since a344308 was a344308, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 6, 2013 at 1:32:22 PM

scheduler: Add and use _Scheduler_default_Tick()

Delete _Scheduler_priority_Tick(). Use _SMP_Get_processor_count() for
default tick operation. Delete _Scheduler_simple_smp_Tick().

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Default 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/scheduler.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/smp.h>
26
27static void _Scheduler_default_Tick_for_executing( Thread_Control *executing )
28{
29  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
30    /*
31     *  Increment the number of ticks this thread has been executing
32     */
33    executing->cpu_time_used++;
34  #endif
35
36  /*
37   *  If the thread is not preemptible or is not ready, then
38   *  just return.
39   */
40
41  if ( !executing->is_preemptible )
42    return;
43
44  if ( !_States_Is_ready( executing->current_state ) )
45    return;
46
47  /*
48   *  The cpu budget algorithm determines what happens next.
49   */
50
51  switch ( executing->budget_algorithm ) {
52    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
53      break;
54
55    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
56    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
57      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
58    #endif
59      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
60
61        /*
62         *  A yield performs the ready chain mechanics needed when
63         *  resetting a timeslice.  If no other thread's are ready
64         *  at the priority of the currently executing thread, then the
65         *  executing thread's timeslice is reset.  Otherwise, the
66         *  currently executing thread is placed at the rear of the
67         *  FIFO for this priority and a new heir is selected.
68         */
69        _Scheduler_Yield( executing );
70        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
71      }
72      break;
73
74    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
75      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
76        if ( --executing->cpu_time_budget == 0 )
77          (*executing->budget_callout)( executing );
78        break;
79    #endif
80  }
81}
82
83void _Scheduler_default_Tick( void )
84{
85  uint32_t processor_count = _SMP_Get_processor_count();
86  uint32_t processor;
87
88  for ( processor = 0 ; processor < processor_count ; ++processor ) {
89    _Scheduler_default_Tick_for_executing(
90      _Per_CPU_Information[ processor ].executing
91    );
92  }
93}
Note: See TracBrowser for help on using the repository browser.