# OS_WakeupThread

## C Specification

      #include <nitro/os.h>

      void OS_WakeupThread( OSThreadQueue*  queue );

## Arguments

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

## Return Values

None.

## Description

Recovers all threads in the specified thread queue.
This function recovers all threads from within the thread queue designated with queue that were paused by `OS_SleepThread()`. After this the threads are scheduled based on priority. Priorities are assigned when the thread is created with `OS_CreateThread`, so if threads have the same priority, the priority depends on the status in the internal list and the user cannot assign priorities. The order that threads are registered in the thread queue is not related to the priorities.

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 );
> :
> }
> }`

## 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

CONFIDENTIAL