[6733466] | 1 | IDLE Thread |
---|
| 2 | ########### |
---|
| 3 | |
---|
| 4 | Does Idle Thread Have a Floating Point Context? |
---|
| 5 | =============================================== |
---|
| 6 | |
---|
| 7 | The setting of the macro CPU_IDLE_TASK_IS_FP is based on the answer to the |
---|
| 8 | question: Should the IDLE task have a floating point context? If the |
---|
| 9 | answer to this question is TRUE, then the IDLE task has a floating point |
---|
| 10 | context associated. This is equivalent to creating a task in the Classic |
---|
| 11 | API (using rtems_task_create) as a RTEMS_FLOATING_POINT task. If |
---|
| 12 | CPU_IDLE_TASK_IS_FP is set to TRUE, then a floating point context switch |
---|
| 13 | occurs when the IDLE task is switched in and out. This adds to the |
---|
| 14 | execution overhead of the system but is necessary on some ports. |
---|
| 15 | |
---|
| 16 | If FALSE, then the IDLE task does not have a floating point context. |
---|
| 17 | |
---|
| 18 | NOTE: Setting CPU_IDLE_TASK_IS_FP to TRUE negatively impacts the time |
---|
| 19 | required to preempt the IDLE task from an interrupt because the floating |
---|
| 20 | point context must be saved as part of the preemption. |
---|
| 21 | |
---|
| 22 | The following illustrates how to set this macro: |
---|
| 23 | .. code:: c |
---|
| 24 | |
---|
| 25 | #define CPU_IDLE_TASK_IS_FP FALSE |
---|
| 26 | |
---|
| 27 | CPU Dependent Idle Thread Body |
---|
| 28 | ============================== |
---|
| 29 | |
---|
| 30 | CPU_PROVIDES_IDLE_THREAD_BODY Macro Setting |
---|
| 31 | ------------------------------------------- |
---|
| 32 | |
---|
| 33 | The CPU_PROVIDES_IDLE_THREAD_BODY macro setting is based upon the answer |
---|
| 34 | to the question: Does this port provide a CPU dependent IDLE task |
---|
| 35 | implementation? If the answer to this question is yes, then the |
---|
| 36 | CPU_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 |
---|
| 38 | default IDLE thread body of _Thread_Idle_body. If the |
---|
| 39 | CPU_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. |
---|
| 41 | Regardless of whether or not a CPU dependent IDLE thread implementation is |
---|
| 42 | provided, the BSP can still override it. |
---|
| 43 | |
---|
| 44 | This is intended to allow for supporting processors which have a low power |
---|
| 45 | or idle mode. When the IDLE thread is executed, then the CPU can be |
---|
| 46 | powered down when the processor is idle. |
---|
| 47 | |
---|
| 48 | The 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 | |
---|
| 56 | The following illustrates setting the CPU_PROVIDES_IDLE_THREAD_BODY macro: |
---|
| 57 | .. code:: c |
---|
| 58 | |
---|
| 59 | #define CPU_PROVIDES_IDLE_THREAD_BODY TRUE |
---|
| 60 | |
---|
| 61 | Implementation details of a CPU model specific IDLE thread body are in the |
---|
| 62 | next section. |
---|
| 63 | |
---|
| 64 | Idle Thread Body |
---|
| 65 | ---------------- |
---|
| 66 | |
---|
| 67 | The _CPU_Thread_Idle_body routine only needs to be provided if the porter |
---|
| 68 | wishes to include a CPU dependent IDLE thread body. If the port includes |
---|
| 69 | a CPU dependent implementation of the IDLE thread body, then the |
---|
| 70 | CPU_PROVIDES_IDLE_THREAD_BODY macro should be defined to TRUE. This |
---|
| 71 | routine is prototyped as follows: |
---|
| 72 | .. code:: c |
---|
| 73 | |
---|
| 74 | void \*_CPU_Thread_Idle_body( uintptr_t ); |
---|
| 75 | |
---|
| 76 | As mentioned above, RTEMS does not require that a CPU dependent IDLE |
---|
| 77 | thread body be provided as part of the port. If |
---|
| 78 | CPU_PROVIDES_IDLE_THREAD_BODY is defined to FALSE, then the CPU |
---|
| 79 | independent algorithm is used. This algorithm consists of a "branch to |
---|
| 80 | self" 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 | |
---|
| 88 | If the CPU dependent IDLE thread body is implementation centers upon using |
---|
| 89 | a "halt", "idle", or "shutdown" instruction, then donât forget to put it |
---|
| 90 | in an infinite loop as the CPU will have to reexecute this instruction |
---|
| 91 | each 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 | |
---|
| 100 | Be warned. Some processors with onboard DMA have been known to stop the |
---|
| 101 | DMA if the CPU were put in IDLE mode. This might also be a problem with |
---|
| 102 | other 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 | |
---|