OS_WakeupThread


C Specification

#include <nitro/os.h>
void OS_WakeupThread( OSThreadQueue*  queue );

Description

This function recovers all threads from within the designated thread queue queue that were paused by OS_SleepThread(). After that, threads are scheduled according to their priority, which are assigned when the thread is created with OS_CreateThread. In the case that threads have the same priority, priority will depend on the status of an internal list. From the user side, which has priority will be undefined. The order of the thread registered in the thread queue has no meaning.

The following is an example of using OS_WakeupThread().

(Example)
#define THREAD1_PRIO 1
#define THREAD2_PRIO 2
#define STACK_SIZE 1024
void proc1( void );
void proc2( void );
OSThread thread1;
OSThread thread2;
OSThreadQueue queue;
u64 stack1[ STACK_SIZE / sizeof(u64) ];
u64 stack2[ STACK_SIZE / sizeof(u64) ];

void nitroMain()
{
  :
  OS_InitThread();
  OS_InitThreadQueue( &queue );
  OS_CreateThread( &thread1, proc1, stack1+STACK_SIZE/sizeof(u64), STACK_SIZE, THREAD1_PRIO );
  OS_CreateThread( &thread2, proc2, stack2+STACK_SIZE/sizeof(u64), STACK_SIZE, THREAD2_PRIO );
  OS_WakeUpThreadDirect( &thread1 );
  OS_WakeUpThreadDirect( &thread2 );
  :
  while(1)
  {
      :
    OS_WakeupThread( &queue );
      :
  }
}

void proc1( void )
{
  while(1)
  {
    :
    OS_SleepThread( &queue );
    :
  }
}

void proc2( void )
{
  while(1)
  {
    :
    OS_SleepThread( &queue );
    :
  }
}

Arguments

queue Pointer to the thread queue where the thread to be recovered is registered.

Return Values

None

See Also

OS_InitThread, OS_CreateThread, OS_SleepThread, OS_WakeupThreadDirect

Revision History

03/12/2004 Changed the description of what happens when there are identical priorities
12/01/2003 Initial Version