OS_SleepThreadDirect

Syntax

#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 is called with thread, the thread will transition from the suspended state to the runnable 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. This function was created for a specialized purpose, so it should not be used on threads that call functions whose implementation details are unclear.

Example:
/* Low-priority thread that will be run first */ thread_1_proc()
{
  critical_task();
}

/* High-priority thread that will be run later */
thread_2_proc()
{
  OS_SleepThreadDirect(thread_1, NULL);
  critical_task();
  OS_WakeupThreadDirect(thread_1);
}

/* Task that will be run by both threads */
critical_task()
{
    Processing that could cause a deadlock if run here:
    - Mutual exclusion-related tasks (LockMutex, etc.)
    - Tasks that may depend on thread execution because of wait matrices and so on (FS functions, etc.)
}

See Also

OS_InitThread
OS_CreateThread
OS_WakeupThread
OS_WakeupThreadDirect
OS_SleepThread

Revision History

2007/12/03 Added a note.
2006/08/29 Added a note related to the method of use.
2006/08/16 Initial version.


CONFIDENTIAL