source: rtems/cpukit/score/src/schedulersimplesmptick.c @ e655f7e

4.115
Last change on this file since e655f7e was e655f7e, checked in by Alex Ivanov <alexivanov97@…>, on 11/29/12 at 18:39:19

score misc: Score misc: Clean up Doxygen #5

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Scheduler Simple SMP Tick Method
5 *  @ingroup ScoreScheduler
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2009.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/score/schedulersimplesmp.h>
23#include <rtems/score/smp.h>
24
25static void _Scheduler_simple_smp_Tick_helper(
26  int cpu
27)
28{
29  Thread_Control *executing;
30  ISR_Level       level;
31
32  executing = _Per_CPU_Information[cpu].executing;
33
34  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
35    /*
36     *  Increment the number of ticks this thread has been executing
37     */
38    executing->cpu_time_used++;
39  #endif
40
41  /*
42   *  If the thread is not preemptible or is not ready, then
43   *  just return.
44   */
45
46  if ( !executing->is_preemptible )
47    return;
48
49  if ( !_States_Is_ready( executing->current_state ) )
50    return;
51
52  /*
53   *  The cpu budget algorithm determines what happens next.
54   */
55
56  switch ( executing->budget_algorithm ) {
57    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
58      break;
59
60    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
61    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
62      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
63    #endif
64      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
65
66        /*
67         *  A yield performs the ready chain mechanics needed when
68         *  resetting a timeslice.  If no other thread's are ready
69         *  at the priority of the currently executing thread, then the
70         *  executing thread's timeslice is reset.  Otherwise, the
71         *  currently executing thread is placed at the rear of the
72         *  FIFO for this priority and a new heir is selected.
73         *
74         *  In the SMP case, we do the chain manipulation for every
75         *  CPU, then schedule after all CPUs have been evaluated.
76         */
77        _ISR_Disable( level );
78          _Scheduler_simple_Ready_queue_requeue( &_Scheduler, executing );
79        _ISR_Enable( level );
80
81        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
82      }
83      break;
84
85    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
86      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
87        if ( --executing->cpu_time_budget == 0 )
88          (*executing->budget_callout)( executing );
89        break;
90    #endif
91  }
92}
93
94void _Scheduler_simple_smp_Tick( void )
95{
96  uint32_t        cpu;
97
98  /*
99   *  Iterate over all cores, updating time slicing information
100   *  and logically performing a yield.  Then perform a schedule
101   *  operation to account for all the changes.
102   */
103  for ( cpu=0 ; cpu < _SMP_Processor_count ; cpu++ ) {
104    _Scheduler_simple_smp_Tick_helper( cpu );
105  }
106  _Scheduler_simple_smp_Schedule();
107}
Note: See TracBrowser for help on using the repository browser.