source: rtems/doc/porting/idlethread.t @ 14780ecf

4.104.114.84.95
Last change on this file since 14780ecf was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

  • SUPPORT, LICENSE: New files.
  • Numerous files touched as part of merging the 4.5 branch onto the mainline development trunk and ensuring that the script that cuts snapshots and releases works on the documentation.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter IDLE Thread
10
11@section Does Idle Thread Have a Floating Point Context?
12
13The setting of the macro CPU_IDLE_TASK_IS_FP is based on the answer to the
14question:  Should the IDLE task have a floating point context?  If the
15answer to this question is TRUE, then the IDLE task has a floating point
16context associated.  This is equivalent to creating a task in the Classic
17API (using rtems_task_create) as a RTEMS_FLOATING_POINT task.  If
18CPU_IDLE_TASK_IS_FP is set to TRUE, then a floating point context switch
19occurs when the IDLE task is switched in and out.  This adds to the
20execution overhead of the system but is necessary on some ports.
21
22If FALSE, then the IDLE task does not have a floating point context.
23
24NOTE: Setting CPU_IDLE_TASK_IS_FP to TRUE negatively impacts the time
25required to preempt the IDLE task from an interrupt because the floating
26point context must be saved as part of the preemption.
27
28The following illustrates how to set this macro:
29
30@example
31#define CPU_IDLE_TASK_IS_FP      FALSE
32@end example
33
34@section CPU Dependent Idle Thread Body
35
36@subsection CPU_PROVIDES_IDLE_THREAD_BODY Macro Setting
37
38The CPU_PROVIDES_IDLE_THREAD_BODY macro setting is based upon the answer
39to the question:  Does this port provide a CPU dependent IDLE task
40implementation?  If the answer to this question is yes, then the
41CPU_PROVIDES_IDLE_THREAD_BODY macro should be set to TRUE, and the routine
42_CPU_Thread_Idle_body must be provided.  This routine overrides the
43default IDLE thread body of _Thread_Idle_body.  If the
44CPU_PROVIDES_IDLE_THREAD_BODY macro is set to FALSE, then the generic
45_Thread_Idle_body is the default IDLE thread body for this port. 
46Regardless of whether or not a CPU dependent IDLE thread implementation is
47provided, the BSP can still override it.
48
49This is intended to allow for supporting processors which have a low power
50or idle mode.  When the IDLE thread is executed, then the CPU can be
51powered down when the processor is idle.
52
53The order of precedence for selecting the IDLE thread body is:
54
55@enumerate
56@item BSP provided
57
58@item CPU dependent (if provided)
59
60@item generic (if no BSP and no CPU dependent)
61
62@end enumerate
63
64The following illustrates setting the CPU_PROVIDES_IDLE_THREAD_BODY macro:
65
66@example
67#define CPU_PROVIDES_IDLE_THREAD_BODY    TRUE
68@end example
69
70Implementation details of a CPU model specific IDLE thread body are in the
71next section.
72
73@subsection Idle Thread Body
74
75The _CPU_Thread_Idle_body routine only needs to be provided if the porter
76wishes to include a CPU dependent IDLE thread body.  If the port includes
77a CPU dependent implementation of the IDLE thread body, then the
78CPU_PROVIDES_IDLE_THREAD_BODY macro should be defined to TRUE.  This
79routine is prototyped as follows:
80
81@example
82void _CPU_Thread_Idle_body( void );
83@end example
84
85As mentioned above, RTEMS does not require that a CPU dependent IDLE
86thread body be provided as part of the port.  If
87CPU_PROVIDES_IDLE_THREAD_BODY is defined to FALSE, then the CPU
88independent algorithm is used.  This algorithm consists of a "branch to
89self" which is implemented in the XXX routine as follows.
90
91@example
92XXX check name and exact implementation
93void _Thread_Idle_body( void )
94@{
95  while( 1 ) ;
96@}
97@end example
98
99If the CPU dependent IDLE thread body is implementation centers upon using
100a "halt", "idle", or "shutdown" instruction, then don't forget to put it
101in an infinite loop as the CPU will have to reexecute this instruction
102each time the IDLE thread is dispatched.
103
104@example
105void _CPU_Thread_Idle_body( void )
106@{
107
108  for( ; ; )
109    /* insert your "halt" instruction here */ ;
110@}
111@end example
112
113Be warned. Some processors with onboard DMA have been known to stop the
114DMA if the CPU were put in IDLE mode.  This might also be a problem with
115other on-chip peripherals.  So use this hook with caution.
116
Note: See TracBrowser for help on using the repository browser.