# OS_SleepThreadDirect

## C Specification

      #include <nitro/os.h>

      void OS_SleepThreadDirect( OSThread* thread, OSThreadQueue*  queue );

## Arguments

thread | Pointer to the thread to be stopped
queue | Pointer to the thread queue that registers the specified thread. If NULL, it is not registered to the thread queue.

## Return Values

None.

## Description

Pauses the specified thread and registers it with the thread queue designated by queue.

When the `OS_WakeupThread` function is called with queue or the `OS_WakeupThreadDirect` function with thread, the thread will transition from the pause state to the executable state.

This function changes the thread state directly from outside without using specific signals, so extreme caution is necessary to avoid unexpected deadlock when used with a wait matrix or tasks involving a mutex.

> (Example)
> `

>     /* Low priority thread executed first */
>     thread_1_proc()
>     {
>         critical_task();
>     }

>     /* High priority thread executed later */
>     thread_2_proc()
>     {
>         OS_SleepThreadDirect(thread_1, NULL);
>         critical_task();
>         OS_WakeupThreadDirect(thread_1);
>     }

>     /* Task executed for both */
>     critical_task()
>     {
>         Processes that may generate deadlock if used here
>         - Those related to exclusive access control (such as LockMutex)
>         - Those resulting in thread execution dependency from wait matrix and such (such as FS function).
>     }

> `

## See Also

`OS_InitThread OS_CreateThread, OS_WakeupThread, OS_WakeupThreadDirect OS_SleepThread`

## Revision History

08/29/2006 Added notes regarding usage.
08/16/2006 Initial version.

CONFIDENTIAL