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

4.115
Last change on this file since e1598a6 was e1598a6, checked in by Sebastian Huber <sebastian.huber@…>, on 04/04/14 at 08:56:36

score: Static scheduler configuration

Do not allocate the scheduler control structures from the workspace.
This is a preparation step for configuration of clustered/partitioned
schedulers on SMP.

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