source: rtems/cpukit/score/src/schedulerdefaulttick.c @ 25f5730f

4.115
Last change on this file since 25f5730f was c5831a3f, checked in by Sebastian Huber <sebastian.huber@…>, on 04/09/14 at 13:07:54

score: Add clustered/partitioned scheduling

Clustered/partitioned scheduling helps to control the worst-case
latencies in the system. The goal is to reduce the amount of shared
state in the system and thus prevention of lock contention. Modern
multi-processor systems tend to have several layers of data and
instruction caches. With clustered/partitioned scheduling it is
possible to honour the cache topology of a system and thus avoid
expensive cache synchronization traffic.

We have clustered scheduling in case the set of processors of a system
is partitioned into non-empty pairwise-disjoint subsets. These subsets
are called clusters. Clusters with a cardinality of one are partitions.
Each cluster is owned by exactly one scheduler instance.

  • Property mode set to 100644
File size: 2.2 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
27void _Scheduler_default_Tick(
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}
Note: See TracBrowser for help on using the repository browser.