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
RevLine 
[e655f7e]1/**
2 *  @file
3 *
4 *  @brief Scheduler Simple SMP Tick Method
5 *  @ingroup ScoreScheduler
6 */
7
[05df0a8]8/*
[dca9a82]9 *  COPYRIGHT (c) 1989-2009.
[05df0a8]10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
[dcf3687]13 *  found in the file LICENSE in this distribution or at
[dd687d97]14 *  http://www.rtems.com/license/LICENSE.
[05df0a8]15 */
16
[a8eed23]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[05df0a8]21#include <rtems/system.h>
[3203e09]22#include <rtems/score/schedulersimplesmp.h>
[c5a4332]23#include <rtems/score/smp.h>
[05df0a8]24
[3203e09]25static void _Scheduler_simple_smp_Tick_helper(
26  int cpu
27)
[05df0a8]28{
29  Thread_Control *executing;
[c5a4332]30  ISR_Level       level;
[05df0a8]31
[3203e09]32  executing = _Per_CPU_Information[cpu].executing;
[05df0a8]33
[c6f7e060]34  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
[c3330a8]35    /*
36     *  Increment the number of ticks this thread has been executing
37     */
[5fa5185]38    executing->cpu_time_used++;
[c3330a8]39  #endif
[05df0a8]40
41  /*
[a0ed4ed]42   *  If the thread is not preemptible or is not ready, then
[05df0a8]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:
[442eac69]61    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
62      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
63    #endif
[c0f4682]64      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
[8bef4cc]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.
[3203e09]73         *
74         *  In the SMP case, we do the chain manipulation for every
75         *  CPU, then schedule after all CPUs have been evaluated.
[8bef4cc]76         */
[3203e09]77        _ISR_Disable( level );
78          _Scheduler_simple_Ready_queue_requeue( &_Scheduler, executing );
79        _ISR_Enable( level );
80
[05df0a8]81        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
82      }
83      break;
84
[442eac69]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
[05df0a8]91  }
92}
[3203e09]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.