source: rtems-docs/porting/idle_thread.rst @ 170418a

4.115
Last change on this file since 170418a was d389819, checked in by Amar Takhar <amar@…>, on 01/18/16 at 05:37:40

Convert all Unicode to ASCII(128)

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