RTEMS Logo

RTEMS 4.9.4 On-Line Library


IDLE Thread Idle Thread Body

PREV UP NEXT Bookshelf RTEMS Porting Guide

7.2.2: Idle Thread Body

The _CPU_Thread_Idle_body routine only needs to be provided if the porter wishes to include a CPU dependent IDLE thread body. If the port includes a CPU dependent implementation of the IDLE thread body, then the CPU_PROVIDES_IDLE_THREAD_BODY macro should be defined to TRUE. This routine is prototyped as follows:

void *_CPU_Thread_Idle_body( uint32_t );

As mentioned above, RTEMS does not require that a CPU dependent IDLE thread body be provided as part of the port. If CPU_PROVIDES_IDLE_THREAD_BODY is defined to FALSE, then the CPU independent algorithm is used. This algorithm consists of a "branch to self" which is implemented in a routine as follows.

void *_Thread_Idle_body( uint32 ignored )
{
  while( 1 ) ;
}

If the CPU dependent IDLE thread body is implementation centers upon using a "halt", "idle", or "shutdown" instruction, then don't forget to put it in an infinite loop as the CPU will have to reexecute this instruction each time the IDLE thread is dispatched.

void *_CPU_Thread_Idle_body( uint32_t ignored )
{

  for( ; ; )
    /* insert your "halt" instruction here */ ;
}

Be warned. Some processors with onboard DMA have been known to stop the DMA if the CPU were put in IDLE mode. This might also be a problem with other on-chip peripherals. So use this hook with caution.


PREV UP NEXT Bookshelf RTEMS Porting Guide

Copyright © 1988-2008 OAR Corporation