xref: /nrf52832-nimble/rt-thread/components/net/uip/doc/html/a00142.html (revision 104654410c56c573564690304ae786df310c91fc)
1*10465441SEvalZero<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2*10465441SEvalZero<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3*10465441SEvalZero<title>uIP 1.0: Protothreads</title>
4*10465441SEvalZero<link href="doxygen.css" rel="stylesheet" type="text/css">
5*10465441SEvalZero<link href="tabs.css" rel="stylesheet" type="text/css">
6*10465441SEvalZero</head><body>
7*10465441SEvalZero<!-- Generated by Doxygen 1.4.6 -->
8*10465441SEvalZero<div class="tabs">
9*10465441SEvalZero  <ul>
10*10465441SEvalZero    <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
11*10465441SEvalZero    <li><a href="modules.html"><span>Modules</span></a></li>
12*10465441SEvalZero    <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
13*10465441SEvalZero    <li><a href="files.html"><span>Files</span></a></li>
14*10465441SEvalZero    <li><a href="examples.html"><span>Examples</span></a></li>
15*10465441SEvalZero  </ul></div>
16*10465441SEvalZero<h1>Protothreads</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
17*10465441SEvalZeroProtothreads are a type of lightweight stackless threads designed for severly memory constrained systems such as deeply embedded systems or sensor network nodes.
18*10465441SEvalZero<p>
19*10465441SEvalZeroProtothreads provides linear code execution for event-driven systems implemented in C. Protothreads can be used with or without an RTOS.<p>
20*10465441SEvalZeroProtothreads are a extremely lightweight, stackless type of threads that provides a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without complex state machines or full multi-threading. Protothreads provides conditional blocking inside C functions.<p>
21*10465441SEvalZeroThe advantage of protothreads over a purely event-driven approach is that protothreads provides a sequential code structure that allows for blocking functions. In purely event-driven systems, blocking must be implemented by manually breaking the function into two pieces - one for the piece of code before the blocking call and one for the code after the blocking call. This makes it hard to use control structures such as if() conditionals and while() loops.<p>
22*10465441SEvalZeroThe advantage of protothreads over ordinary threads is that a protothread do not require a separate stack. In memory constrained systems, the overhead of allocating multiple stacks can consume large amounts of the available memory. In contrast, each protothread only requires between two and twelve bytes of state, depending on the architecture.<p>
23*10465441SEvalZero<dl compact><dt><b>Note:</b></dt><dd>Because protothreads do not save the stack context across a blocking call, <b>local variables are not preserved when the protothread blocks</b>. This means that local variables should be used with utmost care - <b>if in doubt, do not use local variables inside a protothread!</b></dd></dl>
24*10465441SEvalZeroMain features:<p>
25*10465441SEvalZero<ul>
26*10465441SEvalZero<li>No machine specific code - the protothreads library is pure C</li></ul>
27*10465441SEvalZero<p>
28*10465441SEvalZero<ul>
29*10465441SEvalZero<li>Does not use error-prone functions such as longjmp()</li></ul>
30*10465441SEvalZero<p>
31*10465441SEvalZero<ul>
32*10465441SEvalZero<li>Very small RAM overhead - only two bytes per protothread</li></ul>
33*10465441SEvalZero<p>
34*10465441SEvalZero<ul>
35*10465441SEvalZero<li>Can be used with or without an OS</li></ul>
36*10465441SEvalZero<p>
37*10465441SEvalZero<ul>
38*10465441SEvalZero<li>Provides blocking wait without full multi-threading or stack-switching</li></ul>
39*10465441SEvalZero<p>
40*10465441SEvalZeroExamples applications:<p>
41*10465441SEvalZero<ul>
42*10465441SEvalZero<li>Memory constrained systems</li></ul>
43*10465441SEvalZero<p>
44*10465441SEvalZero<ul>
45*10465441SEvalZero<li>Event-driven protocol stacks</li></ul>
46*10465441SEvalZero<p>
47*10465441SEvalZero<ul>
48*10465441SEvalZero<li>Deeply embedded systems</li></ul>
49*10465441SEvalZero<p>
50*10465441SEvalZero<ul>
51*10465441SEvalZero<li>Sensor network nodes</li></ul>
52*10465441SEvalZero<p>
53*10465441SEvalZeroThe protothreads API consists of four basic operations: initialization: <a class="el" href="a00142.html#ge6bae7dc0225468c8a5ac269df549892">PT_INIT()</a>, execution: <a class="el" href="a00142.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a>, conditional blocking: <a class="el" href="a00142.html#g99e43010ec61327164466aa2d902de45">PT_WAIT_UNTIL()</a> and exit: <a class="el" href="a00142.html#g7b04a0035bef29d905496c23bae066d2">PT_END()</a>. On top of these, two convenience functions are built: reversed condition blocking: <a class="el" href="a00142.html#gad14bbbf092b90aa0a5a4f9169504a8d">PT_WAIT_WHILE()</a> and protothread blocking: <a class="el" href="a00142.html#g2f8f70c30b9ee08a103fbd69a4365c4c">PT_WAIT_THREAD()</a>.<p>
54*10465441SEvalZero<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00142.html">Protothreads API documentation</a></dd></dl>
55*10465441SEvalZeroThe protothreads library is released under a BSD-style license that allows for both non-commercial and commercial usage. The only requirement is that credit is given.<h2><a class="anchor" name="authors">
56*10465441SEvalZeroAuthors</a></h2>
57*10465441SEvalZeroThe protothreads library was written by Adam Dunkels &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; with support from Oliver Schmidt &lt;<a href="mailto:[email protected]">[email protected]</a>&gt;.<h2><a class="anchor" name="pt-desc">
58*10465441SEvalZeroProtothreads</a></h2>
59*10465441SEvalZeroProtothreads are a extremely lightweight, stackless threads that provides a blocking context on top of an event-driven system, without the overhead of per-thread stacks. The purpose of protothreads is to implement sequential flow of control without using complex state machines or full multi-threading. Protothreads provides conditional blocking inside a C function.<p>
60*10465441SEvalZeroIn memory constrained systems, such as deeply embedded systems, traditional multi-threading may have a too large memory overhead. In traditional multi-threading, each thread requires its own stack, that typically is over-provisioned. The stacks may use large parts of the available memory.<p>
61*10465441SEvalZeroThe main advantage of protothreads over ordinary threads is that protothreads are very lightweight: a protothread does not require its own stack. Rather, all protothreads run on the same stack and context switching is done by stack rewinding. This is advantageous in memory constrained systems, where a stack for a thread might use a large part of the available memory. A protothread only requires only two bytes of memory per protothread. Moreover, protothreads are implemented in pure C and do not require any machine-specific assembler code.<p>
62*10465441SEvalZeroA protothread runs within a single C function and cannot span over other functions. A protothread may call normal C functions, but cannot block inside a called function. Blocking inside nested function calls is instead made by spawning a separate protothread for each potentially blocking function. The advantage of this approach is that blocking is explicit: the programmer knows exactly which functions that block that which functions the never blocks.<p>
63*10465441SEvalZeroProtothreads are similar to asymmetric co-routines. The main difference is that co-routines uses a separate stack for each co-routine, whereas protothreads are stackless. The most similar mechanism to protothreads are Python generators. These are also stackless constructs, but have a different purpose. Protothreads provides blocking contexts inside a C function, whereas Python generators provide multiple exit points from a generator function.<h2><a class="anchor" name="pt-autovars">
64*10465441SEvalZeroLocal variables</a></h2>
65*10465441SEvalZero<dl compact><dt><b>Note:</b></dt><dd>Because protothreads do not save the stack context across a blocking call, local variables are not preserved when the protothread blocks. This means that local variables should be used with utmost care - if in doubt, do not use local variables inside a protothread!</dd></dl>
66*10465441SEvalZero<h2><a class="anchor" name="pt-scheduling">
67*10465441SEvalZeroScheduling</a></h2>
68*10465441SEvalZeroA protothread is driven by repeated calls to the function in which the protothread is running. Each time the function is called, the protothread will run until it blocks or exits. Thus the scheduling of protothreads is done by the application that uses protothreads.<h2><a class="anchor" name="pt-impl">
69*10465441SEvalZeroImplementation</a></h2>
70*10465441SEvalZeroProtothreads are implemented using <a class="el" href="a00155.html">local continuations</a>. A local continuation represents the current state of execution at a particular place in the program, but does not provide any call history or local variables. A local continuation can be set in a specific function to capture the state of the function. After a local continuation has been set can be resumed in order to restore the state of the function at the point where the local continuation was set.<p>
71*10465441SEvalZeroLocal continuations can be implemented in a variety of ways:<p>
72*10465441SEvalZero<ol type=1>
73*10465441SEvalZero<li>by using machine specific assembler code,</li><li>by using standard C constructs, or</li><li>by using compiler extensions.</li></ol>
74*10465441SEvalZero<p>
75*10465441SEvalZeroThe first way works by saving and restoring the processor state, except for stack pointers, and requires between 16 and 32 bytes of memory per protothread. The exact amount of memory required depends on the architecture.<p>
76*10465441SEvalZeroThe standard C implementation requires only two bytes of state per protothread and utilizes the C switch() statement in a non-obvious way that is similar to Duff's device. This implementation does, however, impose a slight restriction to the code that uses protothreads in that the code cannot use switch() statements itself.<p>
77*10465441SEvalZeroCertain compilers has C extensions that can be used to implement protothreads. GCC supports label pointers that can be used for this purpose. With this implementation, protothreads require 4 bytes of RAM per protothread.
78*10465441SEvalZero<p>
79*10465441SEvalZero<table border="0" cellpadding="0" cellspacing="0">
80*10465441SEvalZero<tr><td></td></tr>
81*10465441SEvalZero<tr><td colspan="2"><br><h2>Files</h2></td></tr>
82*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00128.html">pt.h</a></td></tr>
83*10465441SEvalZero
84*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Protothreads implementation. <br></td></tr>
85*10465441SEvalZero
86*10465441SEvalZero<p>
87*10465441SEvalZero<tr><td colspan="2"><br><h2>Modules</h2></td></tr>
88*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00155.html">Local continuations</a></td></tr>
89*10465441SEvalZero
90*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Local continuations form the basis for implementing protothreads. <br></td></tr>
91*10465441SEvalZero
92*10465441SEvalZero<p>
93*10465441SEvalZero<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
94*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00084.html">pt</a></td></tr>
95*10465441SEvalZero
96*10465441SEvalZero<tr><td colspan="2"><br><h2>Initialization</h2></td></tr>
97*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ge6bae7dc0225468c8a5ac269df549892">PT_INIT</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
98*10465441SEvalZero
99*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a protothread.  <a href="#ge6bae7dc0225468c8a5ac269df549892"></a><br></td></tr>
100*10465441SEvalZero<tr><td colspan="2"><br><h2>Declaration and definition</h2></td></tr>
101*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(name_args)</td></tr>
102*10465441SEvalZero
103*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declaration of a protothread.  <a href="#g3d4c8bd4aada659eb34f5d2ffd3e7901"></a><br></td></tr>
104*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
105*10465441SEvalZero
106*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declare the start of a protothread inside the C function implementing the protothread.  <a href="#g2ffbb9e554e08a343ae2f9de4bedfdfc"></a><br></td></tr>
107*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g7b04a0035bef29d905496c23bae066d2">PT_END</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
108*10465441SEvalZero
109*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declare the end of a protothread.  <a href="#g7b04a0035bef29d905496c23bae066d2"></a><br></td></tr>
110*10465441SEvalZero<tr><td colspan="2"><br><h2>Blocked wait</h2></td></tr>
111*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g99e43010ec61327164466aa2d902de45">PT_WAIT_UNTIL</a>(<a class="el" href="a00084.html">pt</a>, condition)</td></tr>
112*10465441SEvalZero
113*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait until condition is true.  <a href="#g99e43010ec61327164466aa2d902de45"></a><br></td></tr>
114*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#gad14bbbf092b90aa0a5a4f9169504a8d">PT_WAIT_WHILE</a>(<a class="el" href="a00084.html">pt</a>, cond)</td></tr>
115*10465441SEvalZero
116*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait while condition is true.  <a href="#gad14bbbf092b90aa0a5a4f9169504a8d"></a><br></td></tr>
117*10465441SEvalZero<tr><td colspan="2"><br><h2>Hierarchical protothreads</h2></td></tr>
118*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g2f8f70c30b9ee08a103fbd69a4365c4c">PT_WAIT_THREAD</a>(<a class="el" href="a00084.html">pt</a>, thread)</td></tr>
119*10465441SEvalZero
120*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait until a child protothread completes.  <a href="#g2f8f70c30b9ee08a103fbd69a4365c4c"></a><br></td></tr>
121*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN</a>(<a class="el" href="a00084.html">pt</a>, child, thread)</td></tr>
122*10465441SEvalZero
123*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Spawn a child protothread and wait until it exits.  <a href="#g9e97a0b4d5cc7764d8e19758f5da53ae"></a><br></td></tr>
124*10465441SEvalZero<tr><td colspan="2"><br><h2>Exiting and restarting</h2></td></tr>
125*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#gcd3ac045f0a4ae63412e3b3d8780e8ab">PT_RESTART</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
126*10465441SEvalZero
127*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Restart the protothread.  <a href="#gcd3ac045f0a4ae63412e3b3d8780e8ab"></a><br></td></tr>
128*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g905451249dca72ce0385bf2a9ff178ee">PT_EXIT</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
129*10465441SEvalZero
130*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Exit the protothread.  <a href="#g905451249dca72ce0385bf2a9ff178ee"></a><br></td></tr>
131*10465441SEvalZero<tr><td colspan="2"><br><h2>Calling a protothread</h2></td></tr>
132*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#gfa82b860a64b67d25ab3abc21811896f">PT_SCHEDULE</a>(f)</td></tr>
133*10465441SEvalZero
134*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Schedule a protothread.  <a href="#gfa82b860a64b67d25ab3abc21811896f"></a><br></td></tr>
135*10465441SEvalZero<tr><td colspan="2"><br><h2>Yielding from a protothread</h2></td></tr>
136*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g155cba6121323726d02c00284428fed6">PT_YIELD</a>(<a class="el" href="a00084.html">pt</a>)</td></tr>
137*10465441SEvalZero
138*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yield from the current protothread.  <a href="#g155cba6121323726d02c00284428fed6"></a><br></td></tr>
139*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ge3c821e3a388615528efda9d23c7d115">PT_YIELD_UNTIL</a>(<a class="el" href="a00084.html">pt</a>, cond)</td></tr>
140*10465441SEvalZero
141*10465441SEvalZero<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yield from the protothread until a condition occurs.  <a href="#ge3c821e3a388615528efda9d23c7d115"></a><br></td></tr>
142*10465441SEvalZero<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
143*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g7b5319b5b65761a845fcd1500fde4cdc"></a><!-- doxytag: member="pt::PT_WAITING" ref="g7b5319b5b65761a845fcd1500fde4cdc" args="" -->
144*10465441SEvalZero#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g7b5319b5b65761a845fcd1500fde4cdc">PT_WAITING</a>&nbsp;&nbsp;&nbsp;0</td></tr>
145*10465441SEvalZero
146*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gcfae9053e5c107a1aed6b228c917d2ea"></a><!-- doxytag: member="pt::PT_EXITED" ref="gcfae9053e5c107a1aed6b228c917d2ea" args="" -->
147*10465441SEvalZero#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#gcfae9053e5c107a1aed6b228c917d2ea">PT_EXITED</a>&nbsp;&nbsp;&nbsp;1</td></tr>
148*10465441SEvalZero
149*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g9ff1e8936a8a26bff54c05f8a989b93b"></a><!-- doxytag: member="pt::PT_ENDED" ref="g9ff1e8936a8a26bff54c05f8a989b93b" args="" -->
150*10465441SEvalZero#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#g9ff1e8936a8a26bff54c05f8a989b93b">PT_ENDED</a>&nbsp;&nbsp;&nbsp;2</td></tr>
151*10465441SEvalZero
152*10465441SEvalZero<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ge469332907e0617d72d5e2dd4297119d"></a><!-- doxytag: member="pt::PT_YIELDED" ref="ge469332907e0617d72d5e2dd4297119d" args="" -->
153*10465441SEvalZero#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00142.html#ge469332907e0617d72d5e2dd4297119d">PT_YIELDED</a>&nbsp;&nbsp;&nbsp;3</td></tr>
154*10465441SEvalZero
155*10465441SEvalZero</table>
156*10465441SEvalZero<hr><h2>Define Documentation</h2>
157*10465441SEvalZero<a class="anchor" name="g2ffbb9e554e08a343ae2f9de4bedfdfc"></a><!-- doxytag: member="pt.h::PT_BEGIN" ref="g2ffbb9e554e08a343ae2f9de4bedfdfc" args="(pt)" --><p>
158*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
159*10465441SEvalZero  <tr>
160*10465441SEvalZero    <td class="mdRow">
161*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
162*10465441SEvalZero        <tr>
163*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_BEGIN          </td>
164*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
165*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
166*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
167*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
168*10465441SEvalZero          <td class="md" nowrap></td>
169*10465441SEvalZero        </tr>
170*10465441SEvalZero      </table>
171*10465441SEvalZero    </td>
172*10465441SEvalZero  </tr>
173*10465441SEvalZero</table>
174*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
175*10465441SEvalZero  <tr>
176*10465441SEvalZero    <td>
177*10465441SEvalZero      &nbsp;
178*10465441SEvalZero    </td>
179*10465441SEvalZero    <td>
180*10465441SEvalZero
181*10465441SEvalZero<p>
182*10465441SEvalZeroDeclare the start of a protothread inside the C function implementing the protothread.
183*10465441SEvalZero<p>
184*10465441SEvalZeroThis macro is used to declare the starting point of a protothread. It should be placed at the start of the function in which the protothread runs. All C statements above the <a class="el" href="a00142.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> invokation will be executed each time the protothread is scheduled.<p>
185*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
186*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
187*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
188*10465441SEvalZero  </table>
189*10465441SEvalZero</dl>
190*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
191*10465441SEvalZero<a class="el" href="a00048.html#a17">dhcpc.c</a>.</dl>
192*10465441SEvalZero<p>
193*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00115">115</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
194*10465441SEvalZero  </tr>
195*10465441SEvalZero</table>
196*10465441SEvalZero<a class="anchor" name="g7b04a0035bef29d905496c23bae066d2"></a><!-- doxytag: member="pt.h::PT_END" ref="g7b04a0035bef29d905496c23bae066d2" args="(pt)" --><p>
197*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
198*10465441SEvalZero  <tr>
199*10465441SEvalZero    <td class="mdRow">
200*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
201*10465441SEvalZero        <tr>
202*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_END          </td>
203*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
204*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
205*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
206*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
207*10465441SEvalZero          <td class="md" nowrap></td>
208*10465441SEvalZero        </tr>
209*10465441SEvalZero      </table>
210*10465441SEvalZero    </td>
211*10465441SEvalZero  </tr>
212*10465441SEvalZero</table>
213*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
214*10465441SEvalZero  <tr>
215*10465441SEvalZero    <td>
216*10465441SEvalZero      &nbsp;
217*10465441SEvalZero    </td>
218*10465441SEvalZero    <td>
219*10465441SEvalZero
220*10465441SEvalZero<p>
221*10465441SEvalZeroDeclare the end of a protothread.
222*10465441SEvalZero<p>
223*10465441SEvalZeroThis macro is used for declaring that a protothread ends. It must always be used together with a matching <a class="el" href="a00142.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> macro.<p>
224*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
225*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
226*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
227*10465441SEvalZero  </table>
228*10465441SEvalZero</dl>
229*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
230*10465441SEvalZero<a class="el" href="a00048.html#a34">dhcpc.c</a>.</dl>
231*10465441SEvalZero<p>
232*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00127">127</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
233*10465441SEvalZero  </tr>
234*10465441SEvalZero</table>
235*10465441SEvalZero<a class="anchor" name="g905451249dca72ce0385bf2a9ff178ee"></a><!-- doxytag: member="pt.h::PT_EXIT" ref="g905451249dca72ce0385bf2a9ff178ee" args="(pt)" --><p>
236*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
237*10465441SEvalZero  <tr>
238*10465441SEvalZero    <td class="mdRow">
239*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
240*10465441SEvalZero        <tr>
241*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_EXIT          </td>
242*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
243*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
244*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
245*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
246*10465441SEvalZero          <td class="md" nowrap></td>
247*10465441SEvalZero        </tr>
248*10465441SEvalZero      </table>
249*10465441SEvalZero    </td>
250*10465441SEvalZero  </tr>
251*10465441SEvalZero</table>
252*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
253*10465441SEvalZero  <tr>
254*10465441SEvalZero    <td>
255*10465441SEvalZero      &nbsp;
256*10465441SEvalZero    </td>
257*10465441SEvalZero    <td>
258*10465441SEvalZero
259*10465441SEvalZero<p>
260*10465441SEvalZeroExit the protothread.
261*10465441SEvalZero<p>
262*10465441SEvalZeroThis macro causes the protothread to exit. If the protothread was spawned by another protothread, the parent protothread will become unblocked and can continue to run.<p>
263*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
264*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
265*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
266*10465441SEvalZero  </table>
267*10465441SEvalZero</dl>
268*10465441SEvalZero
269*10465441SEvalZero<p>
270*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00246">246</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
271*10465441SEvalZero  </tr>
272*10465441SEvalZero</table>
273*10465441SEvalZero<a class="anchor" name="ge6bae7dc0225468c8a5ac269df549892"></a><!-- doxytag: member="pt.h::PT_INIT" ref="ge6bae7dc0225468c8a5ac269df549892" args="(pt)" --><p>
274*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
275*10465441SEvalZero  <tr>
276*10465441SEvalZero    <td class="mdRow">
277*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
278*10465441SEvalZero        <tr>
279*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_INIT          </td>
280*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
281*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
282*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
283*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
284*10465441SEvalZero          <td class="md" nowrap></td>
285*10465441SEvalZero        </tr>
286*10465441SEvalZero      </table>
287*10465441SEvalZero    </td>
288*10465441SEvalZero  </tr>
289*10465441SEvalZero</table>
290*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
291*10465441SEvalZero  <tr>
292*10465441SEvalZero    <td>
293*10465441SEvalZero      &nbsp;
294*10465441SEvalZero    </td>
295*10465441SEvalZero    <td>
296*10465441SEvalZero
297*10465441SEvalZero<p>
298*10465441SEvalZeroInitialize a protothread.
299*10465441SEvalZero<p>
300*10465441SEvalZeroInitializes a protothread. Initialization must be done prior to starting to execute the protothread.<p>
301*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
302*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
303*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure.</td></tr>
304*10465441SEvalZero  </table>
305*10465441SEvalZero</dl>
306*10465441SEvalZero<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00142.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN()</a> </dd></dl>
307*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
308*10465441SEvalZero<a class="el" href="a00048.html#a41">dhcpc.c</a>.</dl>
309*10465441SEvalZero<p>
310*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00080">80</a> of file <a class="el" href="a00194.html">pt.h</a>.
311*10465441SEvalZero<p>
312*10465441SEvalZeroReferenced by <a class="el" href="a00184.html#l00298">httpd_appcall()</a>.    </td>
313*10465441SEvalZero  </tr>
314*10465441SEvalZero</table>
315*10465441SEvalZero<a class="anchor" name="gcd3ac045f0a4ae63412e3b3d8780e8ab"></a><!-- doxytag: member="pt.h::PT_RESTART" ref="gcd3ac045f0a4ae63412e3b3d8780e8ab" args="(pt)" --><p>
316*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
317*10465441SEvalZero  <tr>
318*10465441SEvalZero    <td class="mdRow">
319*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
320*10465441SEvalZero        <tr>
321*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_RESTART          </td>
322*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
323*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
324*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
325*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
326*10465441SEvalZero          <td class="md" nowrap></td>
327*10465441SEvalZero        </tr>
328*10465441SEvalZero      </table>
329*10465441SEvalZero    </td>
330*10465441SEvalZero  </tr>
331*10465441SEvalZero</table>
332*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
333*10465441SEvalZero  <tr>
334*10465441SEvalZero    <td>
335*10465441SEvalZero      &nbsp;
336*10465441SEvalZero    </td>
337*10465441SEvalZero    <td>
338*10465441SEvalZero
339*10465441SEvalZero<p>
340*10465441SEvalZeroRestart the protothread.
341*10465441SEvalZero<p>
342*10465441SEvalZeroThis macro will block and cause the running protothread to restart its execution at the place of the <a class="el" href="a00142.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> call.<p>
343*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
344*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
345*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
346*10465441SEvalZero  </table>
347*10465441SEvalZero</dl>
348*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
349*10465441SEvalZero<a class="el" href="a00048.html#a27">dhcpc.c</a>.</dl>
350*10465441SEvalZero<p>
351*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00229">229</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
352*10465441SEvalZero  </tr>
353*10465441SEvalZero</table>
354*10465441SEvalZero<a class="anchor" name="gfa82b860a64b67d25ab3abc21811896f"></a><!-- doxytag: member="pt.h::PT_SCHEDULE" ref="gfa82b860a64b67d25ab3abc21811896f" args="(f)" --><p>
355*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
356*10465441SEvalZero  <tr>
357*10465441SEvalZero    <td class="mdRow">
358*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
359*10465441SEvalZero        <tr>
360*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_SCHEDULE          </td>
361*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
362*10465441SEvalZero          <td class="md" nowrap valign="top">f&nbsp;</td>
363*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
364*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
365*10465441SEvalZero          <td class="md" nowrap></td>
366*10465441SEvalZero        </tr>
367*10465441SEvalZero      </table>
368*10465441SEvalZero    </td>
369*10465441SEvalZero  </tr>
370*10465441SEvalZero</table>
371*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
372*10465441SEvalZero  <tr>
373*10465441SEvalZero    <td>
374*10465441SEvalZero      &nbsp;
375*10465441SEvalZero    </td>
376*10465441SEvalZero    <td>
377*10465441SEvalZero
378*10465441SEvalZero<p>
379*10465441SEvalZeroSchedule a protothread.
380*10465441SEvalZero<p>
381*10465441SEvalZeroThis function shedules a protothread. The return value of the function is non-zero if the protothread is running or zero if the protothread has exited.<p>
382*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
383*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
384*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>f</em>&nbsp;</td><td>The call to the C function implementing the protothread to be scheduled </td></tr>
385*10465441SEvalZero  </table>
386*10465441SEvalZero</dl>
387*10465441SEvalZero
388*10465441SEvalZero<p>
389*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00271">271</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
390*10465441SEvalZero  </tr>
391*10465441SEvalZero</table>
392*10465441SEvalZero<a class="anchor" name="g9e97a0b4d5cc7764d8e19758f5da53ae"></a><!-- doxytag: member="pt.h::PT_SPAWN" ref="g9e97a0b4d5cc7764d8e19758f5da53ae" args="(pt, child, thread)" --><p>
393*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
394*10465441SEvalZero  <tr>
395*10465441SEvalZero    <td class="mdRow">
396*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
397*10465441SEvalZero        <tr>
398*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_SPAWN          </td>
399*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
400*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>,         <tr>
401*10465441SEvalZero          <td class="md" nowrap align="right"></td>
402*10465441SEvalZero          <td class="md"></td>
403*10465441SEvalZero          <td class="md" nowrap>child,         <tr>
404*10465441SEvalZero          <td class="md" nowrap align="right"></td>
405*10465441SEvalZero          <td class="md"></td>
406*10465441SEvalZero          <td class="md" nowrap>thread&nbsp;</td>
407*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
408*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
409*10465441SEvalZero          <td class="md" nowrap></td>
410*10465441SEvalZero        </tr>
411*10465441SEvalZero      </table>
412*10465441SEvalZero    </td>
413*10465441SEvalZero  </tr>
414*10465441SEvalZero</table>
415*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
416*10465441SEvalZero  <tr>
417*10465441SEvalZero    <td>
418*10465441SEvalZero      &nbsp;
419*10465441SEvalZero    </td>
420*10465441SEvalZero    <td>
421*10465441SEvalZero
422*10465441SEvalZero<p>
423*10465441SEvalZeroSpawn a child protothread and wait until it exits.
424*10465441SEvalZero<p>
425*10465441SEvalZeroThis macro spawns a child protothread and waits until it exits. The macro can only be used within a protothread.<p>
426*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
427*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
428*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
429*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>child</em>&nbsp;</td><td>A pointer to the child protothread's control structure. </td></tr>
430*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>thread</em>&nbsp;</td><td>The child protothread with arguments </td></tr>
431*10465441SEvalZero  </table>
432*10465441SEvalZero</dl>
433*10465441SEvalZero
434*10465441SEvalZero<p>
435*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00206">206</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
436*10465441SEvalZero  </tr>
437*10465441SEvalZero</table>
438*10465441SEvalZero<a class="anchor" name="g3d4c8bd4aada659eb34f5d2ffd3e7901"></a><!-- doxytag: member="pt.h::PT_THREAD" ref="g3d4c8bd4aada659eb34f5d2ffd3e7901" args="(name_args)" --><p>
439*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
440*10465441SEvalZero  <tr>
441*10465441SEvalZero    <td class="mdRow">
442*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
443*10465441SEvalZero        <tr>
444*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_THREAD          </td>
445*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
446*10465441SEvalZero          <td class="md" nowrap valign="top">name_args&nbsp;</td>
447*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
448*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
449*10465441SEvalZero          <td class="md" nowrap></td>
450*10465441SEvalZero        </tr>
451*10465441SEvalZero      </table>
452*10465441SEvalZero    </td>
453*10465441SEvalZero  </tr>
454*10465441SEvalZero</table>
455*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
456*10465441SEvalZero  <tr>
457*10465441SEvalZero    <td>
458*10465441SEvalZero      &nbsp;
459*10465441SEvalZero    </td>
460*10465441SEvalZero    <td>
461*10465441SEvalZero
462*10465441SEvalZero<p>
463*10465441SEvalZeroDeclaration of a protothread.
464*10465441SEvalZero<p>
465*10465441SEvalZeroThis macro is used to declare a protothread. All protothreads must be declared with this macro.<p>
466*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
467*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
468*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>name_args</em>&nbsp;</td><td>The name and arguments of the C function implementing the protothread. </td></tr>
469*10465441SEvalZero  </table>
470*10465441SEvalZero</dl>
471*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
472*10465441SEvalZero<a class="el" href="a00048.html#a16">dhcpc.c</a>, and <a class="el" href="a00038.html#a165">smtp.c</a>.</dl>
473*10465441SEvalZero<p>
474*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00100">100</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
475*10465441SEvalZero  </tr>
476*10465441SEvalZero</table>
477*10465441SEvalZero<a class="anchor" name="g2f8f70c30b9ee08a103fbd69a4365c4c"></a><!-- doxytag: member="pt.h::PT_WAIT_THREAD" ref="g2f8f70c30b9ee08a103fbd69a4365c4c" args="(pt, thread)" --><p>
478*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
479*10465441SEvalZero  <tr>
480*10465441SEvalZero    <td class="mdRow">
481*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
482*10465441SEvalZero        <tr>
483*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_WAIT_THREAD          </td>
484*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
485*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>,         <tr>
486*10465441SEvalZero          <td class="md" nowrap align="right"></td>
487*10465441SEvalZero          <td class="md"></td>
488*10465441SEvalZero          <td class="md" nowrap>thread&nbsp;</td>
489*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
490*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
491*10465441SEvalZero          <td class="md" nowrap></td>
492*10465441SEvalZero        </tr>
493*10465441SEvalZero      </table>
494*10465441SEvalZero    </td>
495*10465441SEvalZero  </tr>
496*10465441SEvalZero</table>
497*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
498*10465441SEvalZero  <tr>
499*10465441SEvalZero    <td>
500*10465441SEvalZero      &nbsp;
501*10465441SEvalZero    </td>
502*10465441SEvalZero    <td>
503*10465441SEvalZero
504*10465441SEvalZero<p>
505*10465441SEvalZeroBlock and wait until a child protothread completes.
506*10465441SEvalZero<p>
507*10465441SEvalZeroThis macro schedules a child protothread. The current protothread will block until the child protothread completes.<p>
508*10465441SEvalZero<dl compact><dt><b>Note:</b></dt><dd>The child protothread must be manually initialized with the <a class="el" href="a00142.html#ge6bae7dc0225468c8a5ac269df549892">PT_INIT()</a> function before this function is used.</dd></dl>
509*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
510*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
511*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
512*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>thread</em>&nbsp;</td><td>The child protothread with arguments</td></tr>
513*10465441SEvalZero  </table>
514*10465441SEvalZero</dl>
515*10465441SEvalZero<dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00142.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN()</a> </dd></dl>
516*10465441SEvalZero
517*10465441SEvalZero<p>
518*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00192">192</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
519*10465441SEvalZero  </tr>
520*10465441SEvalZero</table>
521*10465441SEvalZero<a class="anchor" name="g99e43010ec61327164466aa2d902de45"></a><!-- doxytag: member="pt.h::PT_WAIT_UNTIL" ref="g99e43010ec61327164466aa2d902de45" args="(pt, condition)" --><p>
522*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
523*10465441SEvalZero  <tr>
524*10465441SEvalZero    <td class="mdRow">
525*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
526*10465441SEvalZero        <tr>
527*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_WAIT_UNTIL          </td>
528*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
529*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>,         <tr>
530*10465441SEvalZero          <td class="md" nowrap align="right"></td>
531*10465441SEvalZero          <td class="md"></td>
532*10465441SEvalZero          <td class="md" nowrap>condition&nbsp;</td>
533*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
534*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
535*10465441SEvalZero          <td class="md" nowrap></td>
536*10465441SEvalZero        </tr>
537*10465441SEvalZero      </table>
538*10465441SEvalZero    </td>
539*10465441SEvalZero  </tr>
540*10465441SEvalZero</table>
541*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
542*10465441SEvalZero  <tr>
543*10465441SEvalZero    <td>
544*10465441SEvalZero      &nbsp;
545*10465441SEvalZero    </td>
546*10465441SEvalZero    <td>
547*10465441SEvalZero
548*10465441SEvalZero<p>
549*10465441SEvalZeroBlock and wait until condition is true.
550*10465441SEvalZero<p>
551*10465441SEvalZeroThis macro blocks the protothread until the specified condition is true.<p>
552*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
553*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
554*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
555*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>condition</em>&nbsp;</td><td>The condition. </td></tr>
556*10465441SEvalZero  </table>
557*10465441SEvalZero</dl>
558*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
559*10465441SEvalZero<a class="el" href="a00048.html#a24">dhcpc.c</a>.</dl>
560*10465441SEvalZero<p>
561*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00148">148</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
562*10465441SEvalZero  </tr>
563*10465441SEvalZero</table>
564*10465441SEvalZero<a class="anchor" name="gad14bbbf092b90aa0a5a4f9169504a8d"></a><!-- doxytag: member="pt.h::PT_WAIT_WHILE" ref="gad14bbbf092b90aa0a5a4f9169504a8d" args="(pt, cond)" --><p>
565*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
566*10465441SEvalZero  <tr>
567*10465441SEvalZero    <td class="mdRow">
568*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
569*10465441SEvalZero        <tr>
570*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_WAIT_WHILE          </td>
571*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
572*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>,         <tr>
573*10465441SEvalZero          <td class="md" nowrap align="right"></td>
574*10465441SEvalZero          <td class="md"></td>
575*10465441SEvalZero          <td class="md" nowrap>cond&nbsp;</td>
576*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
577*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
578*10465441SEvalZero          <td class="md" nowrap></td>
579*10465441SEvalZero        </tr>
580*10465441SEvalZero      </table>
581*10465441SEvalZero    </td>
582*10465441SEvalZero  </tr>
583*10465441SEvalZero</table>
584*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
585*10465441SEvalZero  <tr>
586*10465441SEvalZero    <td>
587*10465441SEvalZero      &nbsp;
588*10465441SEvalZero    </td>
589*10465441SEvalZero    <td>
590*10465441SEvalZero
591*10465441SEvalZero<p>
592*10465441SEvalZeroBlock and wait while condition is true.
593*10465441SEvalZero<p>
594*10465441SEvalZeroThis function blocks and waits while condition is true. See <a class="el" href="a00142.html#g99e43010ec61327164466aa2d902de45">PT_WAIT_UNTIL()</a>.<p>
595*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
596*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
597*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
598*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>cond</em>&nbsp;</td><td>The condition. </td></tr>
599*10465441SEvalZero  </table>
600*10465441SEvalZero</dl>
601*10465441SEvalZero
602*10465441SEvalZero<p>
603*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00167">167</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
604*10465441SEvalZero  </tr>
605*10465441SEvalZero</table>
606*10465441SEvalZero<a class="anchor" name="g155cba6121323726d02c00284428fed6"></a><!-- doxytag: member="pt.h::PT_YIELD" ref="g155cba6121323726d02c00284428fed6" args="(pt)" --><p>
607*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
608*10465441SEvalZero  <tr>
609*10465441SEvalZero    <td class="mdRow">
610*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
611*10465441SEvalZero        <tr>
612*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_YIELD          </td>
613*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
614*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>&nbsp;</td>
615*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
616*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
617*10465441SEvalZero          <td class="md" nowrap></td>
618*10465441SEvalZero        </tr>
619*10465441SEvalZero      </table>
620*10465441SEvalZero    </td>
621*10465441SEvalZero  </tr>
622*10465441SEvalZero</table>
623*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
624*10465441SEvalZero  <tr>
625*10465441SEvalZero    <td>
626*10465441SEvalZero      &nbsp;
627*10465441SEvalZero    </td>
628*10465441SEvalZero    <td>
629*10465441SEvalZero
630*10465441SEvalZero<p>
631*10465441SEvalZeroYield from the current protothread.
632*10465441SEvalZero<p>
633*10465441SEvalZeroThis function will yield the protothread, thereby allowing other processing to take place in the system.<p>
634*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
635*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
636*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
637*10465441SEvalZero  </table>
638*10465441SEvalZero</dl>
639*10465441SEvalZero<dl compact><dt><b>Examples: </b></dt><dd>
640*10465441SEvalZero<a class="el" href="a00048.html#a33">dhcpc.c</a>.</dl>
641*10465441SEvalZero<p>
642*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00290">290</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
643*10465441SEvalZero  </tr>
644*10465441SEvalZero</table>
645*10465441SEvalZero<a class="anchor" name="ge3c821e3a388615528efda9d23c7d115"></a><!-- doxytag: member="pt.h::PT_YIELD_UNTIL" ref="ge3c821e3a388615528efda9d23c7d115" args="(pt, cond)" --><p>
646*10465441SEvalZero<table class="mdTable" cellpadding="2" cellspacing="0">
647*10465441SEvalZero  <tr>
648*10465441SEvalZero    <td class="mdRow">
649*10465441SEvalZero      <table cellpadding="0" cellspacing="0" border="0">
650*10465441SEvalZero        <tr>
651*10465441SEvalZero          <td class="md" nowrap valign="top">#define PT_YIELD_UNTIL          </td>
652*10465441SEvalZero          <td class="md" valign="top">(&nbsp;</td>
653*10465441SEvalZero          <td class="md" nowrap valign="top"><a class="el" href="a00084.html">pt</a>,         <tr>
654*10465441SEvalZero          <td class="md" nowrap align="right"></td>
655*10465441SEvalZero          <td class="md"></td>
656*10465441SEvalZero          <td class="md" nowrap>cond&nbsp;</td>
657*10465441SEvalZero          <td class="mdname1" valign="top" nowrap>          </td>
658*10465441SEvalZero          <td class="md" valign="top">&nbsp;)&nbsp;</td>
659*10465441SEvalZero          <td class="md" nowrap></td>
660*10465441SEvalZero        </tr>
661*10465441SEvalZero      </table>
662*10465441SEvalZero    </td>
663*10465441SEvalZero  </tr>
664*10465441SEvalZero</table>
665*10465441SEvalZero<table cellspacing="5" cellpadding="0" border="0">
666*10465441SEvalZero  <tr>
667*10465441SEvalZero    <td>
668*10465441SEvalZero      &nbsp;
669*10465441SEvalZero    </td>
670*10465441SEvalZero    <td>
671*10465441SEvalZero
672*10465441SEvalZero<p>
673*10465441SEvalZeroYield from the protothread until a condition occurs.
674*10465441SEvalZero<p>
675*10465441SEvalZero<dl compact><dt><b>Parameters:</b></dt><dd>
676*10465441SEvalZero  <table border="0" cellspacing="2" cellpadding="0">
677*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
678*10465441SEvalZero    <tr><td valign="top"></td><td valign="top"><em>cond</em>&nbsp;</td><td>The condition.</td></tr>
679*10465441SEvalZero  </table>
680*10465441SEvalZero</dl>
681*10465441SEvalZeroThis function will yield the protothread, until the specified condition evaluates to true.
682*10465441SEvalZero<p>
683*10465441SEvalZeroDefinition at line <a class="el" href="a00194.html#l00310">310</a> of file <a class="el" href="a00194.html">pt.h</a>.    </td>
684*10465441SEvalZero  </tr>
685*10465441SEvalZero</table>
686*10465441SEvalZero<hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by&nbsp;
687*10465441SEvalZero<a href="http://www.doxygen.org/index.html">
688*10465441SEvalZero<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
689*10465441SEvalZero</body>
690*10465441SEvalZero</html>
691