1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.0.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>OS_SleepThreadDirect</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">OS_SleepThreadDirect <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12<H2>Syntax</H2> 13<DL> 14 <DD> 15 <PRE><CODE>#include <nitro/os.h></CODE></PRE> 16 <PRE><CODE>void OS_SleepThreadDirect( OSThread* thread, OSThreadQueue* queue );</CODE></PRE> 17</DL> 18<H2>Arguments</H2> 19<TABLE border="1" width="100%"> 20 <TBODY> 21 <TR> 22<TD width="13%"><CODE>thread</CODE></TD> 23<TD width="87%">Pointer to the thread to be stopped</TD> 24 </TR> 25 <TR> 26<TD width="13%"><CODE>queue</CODE></TD> 27<TD width="87%">Pointer to the thread queue that registers the specified thread.<BR>If <CODE>NULL</CODE>, it is not registered to the thread queue.</TD> 28 </TR> 29 </TBODY> 30</TABLE> 31<H2>Return Values</H2> 32<P>None.</P> 33<H2>Description</H2> 34<P>Pauses the specified thread and registers it with the thread queue designated by <CODE>queue</CODE>.</P> 35<P>When the <A href="OS_WakeupThread.html"><CODE>OS_WakeupThread</CODE></A> function is called with <CODE>queue</CODE> or the <A href="OS_WakeupThreadDirect.html"><CODE>OS_WakeupThreadDirect</CODE></A> function is called with <CODE>thread</CODE>, the thread will transition from the suspended state to the runnable state.</P> 36<p>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 <FONT color="#ff0000">it should not be used on threads that call functions whose implementation details are unclear</FONT>.<BR> 37</p> 38 39<blockquote>Example: 40 41<PRE>/* Low-priority thread that will be run first */ thread_1_proc() 42{ 43 critical_task(); 44} 45 46/* High-priority thread that will be run later */ 47thread_2_proc() 48{ 49 OS_SleepThreadDirect(thread_1, NULL); 50 critical_task(); 51 OS_WakeupThreadDirect(thread_1); 52} 53 54/* Task that will be run by both threads */ 55critical_task() 56{ 57 <FONT color="#ff0000"> Processing that could cause a deadlock if run here:</FONT> 58 <FONT color="#ff0000"> - Mutual exclusion-related tasks (LockMutex, etc.)</FONT> 59 <FONT color="#ff0000"> - Tasks that may depend on thread execution because of wait matrices and so on (FS functions, etc.)</FONT> 60} 61</PRE></blockquote> 62 63<H2>See Also</H2> 64<P><A href="OS_InitThread.html"><CODE>OS_InitThread</CODE></A><BR> 65<A href="OS_CreateThread.html"><CODE>OS_CreateThread</CODE></A><BR> 66<A href="OS_WakeupThread.html"><CODE>OS_WakeupThread</CODE></A><BR> 67<A href="OS_WakeupThreadDirect.html"><CODE>OS_WakeupThreadDirect</CODE></A><BR> 68<A href="OS_SleepThread.html"><CODE>OS_SleepThread</CODE></A></P> 69<H2>Revision History</H2> 70<P>2007/12/03 Added a note.<BR> 712006/08/29 Added a note related to the method of use.<br>2006/08/16 Initial version.</P> 72<hr><p>CONFIDENTIAL</p></body></HTML>