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