RTEMS
schedulerdefaulttick.c
Go to the documentation of this file.
1 
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 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
23 #include <rtems/score/threadimpl.h>
24 #include <rtems/score/smp.h>
25 #include <rtems/config.h>
26 
28  const Scheduler_Control *scheduler,
29  Thread_Control *executing
30 )
31 {
32  (void) scheduler;
33 
34  /*
35  * If the thread is not preemptible or is not ready, then
36  * just return.
37  */
38 
39  if ( !executing->is_preemptible )
40  return;
41 
42  if ( !_States_Is_ready( executing->current_state ) )
43  return;
44 
45  /*
46  * The cpu budget algorithm determines what happens next.
47  */
48 
49  switch ( executing->budget_algorithm ) {
50  case THREAD_CPU_BUDGET_ALGORITHM_NONE:
51  break;
52 
53  case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
54  #if defined(RTEMS_SCORE_THREAD_ENABLE_EXHAUST_TIMESLICE)
55  case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
56  #endif
57  if ( (int)(--executing->cpu_time_budget) <= 0 ) {
58 
59  /*
60  * A yield performs the ready chain mechanics needed when
61  * resetting a timeslice. If no other thread's are ready
62  * at the priority of the currently executing thread, then the
63  * executing thread's timeslice is reset. Otherwise, the
64  * currently executing thread is placed at the rear of the
65  * FIFO for this priority and a new heir is selected.
66  */
67  _Thread_Yield( executing );
68  executing->cpu_time_budget =
70  }
71  break;
72 
73  #if defined(RTEMS_SCORE_THREAD_ENABLE_SCHEDULER_CALLOUT)
74  case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
75  if ( --executing->cpu_time_budget == 0 )
76  (*executing->budget_callout)( executing );
77  break;
78  #endif
79  }
80 }
void _Thread_Yield(Thread_Control *executing)
Yields the currently executing thread.
Definition: threadyield.c:30
Thread_CPU_budget_algorithm_callout budget_callout
Definition: thread.h:816
#define rtems_configuration_get_ticks_per_timeslice()
Returns the clock ticks per timeslice configured for this application.
Definition: config.h:277
bool is_preemptible
Definition: thread.h:795
Inlined Routines Associated with the Manipulation of the Scheduler.
This header file defines parts of the application configuration information API.
SuperCore SMP Support API.
Thread_CPU_budget_algorithms budget_algorithm
Definition: thread.h:814
States_Control current_state
Definition: thread.h:749
static __inline__ bool _States_Is_ready(States_Control the_states)
Checks if the state is ready.
Definition: statesimpl.h:195
Scheduler control.
Definition: scheduler.h:264
void _Scheduler_default_Tick(const Scheduler_Control *scheduler, Thread_Control *executing)
Performs tick operations depending on the CPU budget algorithm for each executing thread...
Inlined Routines from the Thread Handler.
uint32_t cpu_time_budget
Definition: thread.h:809