source: rtems/cpukit/score/src/schedulerprioritytick.c @ 3203e09

4.115
Last change on this file since 3203e09 was 3203e09, checked in by Joel Sherrill <joel.sherrill@…>, on 06/17/11 at 14:31:46

2011-06-17 Joel Sherrill <joel.sherrill@…>

PR 1819/cpukit

  • rtems/src/clocktick.c, score/Makefile.am, score/include/rtems/score/scheduler.h, score/include/rtems/score/schedulerpriority.h, score/include/rtems/score/schedulersimple.h, score/include/rtems/score/schedulersimplesmp.h, score/include/rtems/score/thread.h, score/inline/rtems/score/scheduler.inl: Add a scheduler entry point which is invoked at each clock tick. _Thread_Tickle_timeslice() is now a method owned by the Deterministic Priority Scheduler and shared by the Simple Priority Scheduler. The Simple SMP Scheduler has its own variation on this which does timeslicing bookkeeping on all cores.
  • score/src/schedulerprioritytick.c, score/src/schedulersimplesmptick.c: New files.
  • score/src/threadtickletimeslice.c: Removed.
  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/schedulerpriority.h>
18
19void _Scheduler_priority_Tick( void )
20{
21  Thread_Control *executing;
22
23  executing = _Thread_Executing;
24
25  #ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
26    /*
27     *  Increment the number of ticks this thread has been executing
28     */
29    executing->cpu_time_used++;
30  #endif
31
32  /*
33   *  If the thread is not preemptible or is not ready, then
34   *  just return.
35   */
36
37  if ( !executing->is_preemptible )
38    return;
39
40  if ( !_States_Is_ready( executing->current_state ) )
41    return;
42
43  /*
44   *  The cpu budget algorithm determines what happens next.
45   */
46
47  switch ( executing->budget_algorithm ) {
48    case THREAD_CPU_BUDGET_ALGORITHM_NONE:
49      break;
50
51    case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
52    #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
53      case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
54    #endif
55      if ( (int)(--executing->cpu_time_budget) <= 0 ) {
56
57        /*
58         *  A yield performs the ready chain mechanics needed when
59         *  resetting a timeslice.  If no other thread's are ready
60         *  at the priority of the currently executing thread, then the
61         *  executing thread's timeslice is reset.  Otherwise, the
62         *  currently executing thread is placed at the rear of the
63         *  FIFO for this priority and a new heir is selected.
64         */
65        _Scheduler_Yield();
66        executing->cpu_time_budget = _Thread_Ticks_per_timeslice;
67      }
68      break;
69
70    #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
71      case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
72        if ( --executing->cpu_time_budget == 0 )
73          (*executing->budget_callout)( executing );
74        break;
75    #endif
76  }
77}
Note: See TracBrowser for help on using the repository browser.