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.

When thread is not in an executable state, this function does nothing and returns.This is done to prevent the queue list from being destroyed because a paused thread registered in another thread queue is also registered in still another thread queue.

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 to be executed first */
thread_1_proc()
{
critical_task();
}

/* High priority threads are executed later. */
thread_2_proc()
{
OS_SleepThreadDirect(thread_1, NULL);
critical_task();
OS_WakeupThreadDirect(thread_1);
}

/* Tasks executed in common */
critical_task()
{
  If executed here, the process may result in a deadlock.
  - Functions related to exclusive control (such as LockMutex)
  - Functions (such as FS) for which thread execution dependencies may arise due to the queue, etc.
}

See Also

OS_InitThread
OS_CreateThread
OS_WakeupThread
OS_WakeupThreadDirect
OS_SleepThread

Revision History

2009/11/19 Explained that nothing happens when the thread is not in an executable state.
2007/12/03 Added notes.
2006/08/29 Added notes regarding how to use the function.
2006/08/16 Initial version.


CONFIDENTIAL