a00014.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  3. <title>The Protothreads Library 1.4: Protothreads</title>
  4. <link href="doxygen.css" rel="stylesheet" type="text/css">
  5. <link href="tabs.css" rel="stylesheet" type="text/css">
  6. </head><body>
  7. <!-- Generated by Doxygen 1.4.6 -->
  8. <div class="tabs">
  9. <ul>
  10. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  11. <li><a href="modules.html"><span>Modules</span></a></li>
  12. <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
  13. <li><a href="files.html"><span>Files</span></a></li>
  14. </ul></div>
  15. <h1>Protothreads</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
  16. Protothreads are implemented in a single header file, <a class="el" href="a00013.html">pt.h</a>, which includes the local continuations header file, <a class="el" href="a00011.html">lc.h</a>.
  17. <p>
  18. This file in turn includes the actual implementation of local continuations, which typically also is contained in a single header file.
  19. <p>
  20. <table border="0" cellpadding="0" cellspacing="0">
  21. <tr><td></td></tr>
  22. <tr><td colspan="2"><br><h2>Files</h2></td></tr>
  23. <tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00013.html">pt.h</a></td></tr>
  24. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Protothreads implementation. <br></td></tr>
  25. <p>
  26. <tr><td colspan="2"><br><h2>Modules</h2></td></tr>
  27. <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00016.html">Protothread semaphores</a></td></tr>
  28. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">This module implements counting semaphores on top of protothreads. <br></td></tr>
  29. <p>
  30. <tr><td class="memItemLeft" nowrap align="right" valign="top">&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00017.html">Local continuations</a></td></tr>
  31. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Local continuations form the basis for implementing protothreads. <br></td></tr>
  32. <p>
  33. <tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
  34. <tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00005.html">pt</a></td></tr>
  35. <tr><td colspan="2"><br><h2>Initialization</h2></td></tr>
  36. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#ge6bae7dc0225468c8a5ac269df549892">PT_INIT</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  37. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Initialize a protothread. <a href="#ge6bae7dc0225468c8a5ac269df549892"></a><br></td></tr>
  38. <tr><td colspan="2"><br><h2>Declaration and definition</h2></td></tr>
  39. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g3d4c8bd4aada659eb34f5d2ffd3e7901">PT_THREAD</a>(name_args)</td></tr>
  40. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declaration of a protothread. <a href="#g3d4c8bd4aada659eb34f5d2ffd3e7901"></a><br></td></tr>
  41. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  42. <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>
  43. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g7b04a0035bef29d905496c23bae066d2">PT_END</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  44. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Declare the end of a protothread. <a href="#g7b04a0035bef29d905496c23bae066d2"></a><br></td></tr>
  45. <tr><td colspan="2"><br><h2>Blocked wait</h2></td></tr>
  46. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g99e43010ec61327164466aa2d902de45">PT_WAIT_UNTIL</a>(<a class="el" href="a00005.html">pt</a>, condition)</td></tr>
  47. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait until condition is true. <a href="#g99e43010ec61327164466aa2d902de45"></a><br></td></tr>
  48. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#gad14bbbf092b90aa0a5a4f9169504a8d">PT_WAIT_WHILE</a>(<a class="el" href="a00005.html">pt</a>, cond)</td></tr>
  49. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait while condition is true. <a href="#gad14bbbf092b90aa0a5a4f9169504a8d"></a><br></td></tr>
  50. <tr><td colspan="2"><br><h2>Hierarchical protothreads</h2></td></tr>
  51. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g2f8f70c30b9ee08a103fbd69a4365c4c">PT_WAIT_THREAD</a>(<a class="el" href="a00005.html">pt</a>, thread)</td></tr>
  52. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Block and wait until a child protothread completes. <a href="#g2f8f70c30b9ee08a103fbd69a4365c4c"></a><br></td></tr>
  53. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN</a>(<a class="el" href="a00005.html">pt</a>, child, thread)</td></tr>
  54. <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>
  55. <tr><td colspan="2"><br><h2>Exiting and restarting</h2></td></tr>
  56. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#gcd3ac045f0a4ae63412e3b3d8780e8ab">PT_RESTART</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  57. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Restart the protothread. <a href="#gcd3ac045f0a4ae63412e3b3d8780e8ab"></a><br></td></tr>
  58. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g905451249dca72ce0385bf2a9ff178ee">PT_EXIT</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  59. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Exit the protothread. <a href="#g905451249dca72ce0385bf2a9ff178ee"></a><br></td></tr>
  60. <tr><td colspan="2"><br><h2>Calling a protothread</h2></td></tr>
  61. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#gfa82b860a64b67d25ab3abc21811896f">PT_SCHEDULE</a>(f)</td></tr>
  62. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Schedule a protothread. <a href="#gfa82b860a64b67d25ab3abc21811896f"></a><br></td></tr>
  63. <tr><td colspan="2"><br><h2>Yielding from a protothread</h2></td></tr>
  64. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g155cba6121323726d02c00284428fed6">PT_YIELD</a>(<a class="el" href="a00005.html">pt</a>)</td></tr>
  65. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yield from the current protothread. <a href="#g155cba6121323726d02c00284428fed6"></a><br></td></tr>
  66. <tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#ge3c821e3a388615528efda9d23c7d115">PT_YIELD_UNTIL</a>(<a class="el" href="a00005.html">pt</a>, cond)</td></tr>
  67. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Yield from the protothread until a condition occurs. <a href="#ge3c821e3a388615528efda9d23c7d115"></a><br></td></tr>
  68. <tr><td colspan="2"><br><h2>Defines</h2></td></tr>
  69. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g7b5319b5b65761a845fcd1500fde4cdc"></a><!-- doxytag: member="pt::PT_WAITING" ref="g7b5319b5b65761a845fcd1500fde4cdc" args="" -->
  70. #define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g7b5319b5b65761a845fcd1500fde4cdc">PT_WAITING</a>&nbsp;&nbsp;&nbsp;0</td></tr>
  71. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="ge469332907e0617d72d5e2dd4297119d"></a><!-- doxytag: member="pt::PT_YIELDED" ref="ge469332907e0617d72d5e2dd4297119d" args="" -->
  72. #define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#ge469332907e0617d72d5e2dd4297119d">PT_YIELDED</a>&nbsp;&nbsp;&nbsp;1</td></tr>
  73. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gcfae9053e5c107a1aed6b228c917d2ea"></a><!-- doxytag: member="pt::PT_EXITED" ref="gcfae9053e5c107a1aed6b228c917d2ea" args="" -->
  74. #define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#gcfae9053e5c107a1aed6b228c917d2ea">PT_EXITED</a>&nbsp;&nbsp;&nbsp;2</td></tr>
  75. <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g9ff1e8936a8a26bff54c05f8a989b93b"></a><!-- doxytag: member="pt::PT_ENDED" ref="g9ff1e8936a8a26bff54c05f8a989b93b" args="" -->
  76. #define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00014.html#g9ff1e8936a8a26bff54c05f8a989b93b">PT_ENDED</a>&nbsp;&nbsp;&nbsp;3</td></tr>
  77. </table>
  78. <hr><h2>Define Documentation</h2>
  79. <a class="anchor" name="g2ffbb9e554e08a343ae2f9de4bedfdfc"></a><!-- doxytag: member="pt.h::PT_BEGIN" ref="g2ffbb9e554e08a343ae2f9de4bedfdfc" args="(pt)" --><p>
  80. <table class="mdTable" cellpadding="2" cellspacing="0">
  81. <tr>
  82. <td class="mdRow">
  83. <table cellpadding="0" cellspacing="0" border="0">
  84. <tr>
  85. <td class="md" nowrap valign="top">#define PT_BEGIN </td>
  86. <td class="md" valign="top">(&nbsp;</td>
  87. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  88. <td class="mdname1" valign="top" nowrap> </td>
  89. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  90. <td class="md" nowrap></td>
  91. </tr>
  92. </table>
  93. </td>
  94. </tr>
  95. </table>
  96. <table cellspacing="5" cellpadding="0" border="0">
  97. <tr>
  98. <td>
  99. &nbsp;
  100. </td>
  101. <td>
  102. <p>
  103. Declare the start of a protothread inside the C function implementing the protothread.
  104. <p>
  105. This 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="a00014.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> invokation will be executed each time the protothread is scheduled.<p>
  106. <dl compact><dt><b>Parameters:</b></dt><dd>
  107. <table border="0" cellspacing="2" cellpadding="0">
  108. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  109. </table>
  110. </dl>
  111. <p>
  112. Definition at line <a class="el" href="a00022.html#l00115">115</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  113. </tr>
  114. </table>
  115. <a class="anchor" name="g7b04a0035bef29d905496c23bae066d2"></a><!-- doxytag: member="pt.h::PT_END" ref="g7b04a0035bef29d905496c23bae066d2" args="(pt)" --><p>
  116. <table class="mdTable" cellpadding="2" cellspacing="0">
  117. <tr>
  118. <td class="mdRow">
  119. <table cellpadding="0" cellspacing="0" border="0">
  120. <tr>
  121. <td class="md" nowrap valign="top">#define PT_END </td>
  122. <td class="md" valign="top">(&nbsp;</td>
  123. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  124. <td class="mdname1" valign="top" nowrap> </td>
  125. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  126. <td class="md" nowrap></td>
  127. </tr>
  128. </table>
  129. </td>
  130. </tr>
  131. </table>
  132. <table cellspacing="5" cellpadding="0" border="0">
  133. <tr>
  134. <td>
  135. &nbsp;
  136. </td>
  137. <td>
  138. <p>
  139. Declare the end of a protothread.
  140. <p>
  141. This macro is used for declaring that a protothread ends. It must always be used together with a matching <a class="el" href="a00014.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> macro.<p>
  142. <dl compact><dt><b>Parameters:</b></dt><dd>
  143. <table border="0" cellspacing="2" cellpadding="0">
  144. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  145. </table>
  146. </dl>
  147. <p>
  148. Definition at line <a class="el" href="a00022.html#l00127">127</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  149. </tr>
  150. </table>
  151. <a class="anchor" name="g905451249dca72ce0385bf2a9ff178ee"></a><!-- doxytag: member="pt.h::PT_EXIT" ref="g905451249dca72ce0385bf2a9ff178ee" args="(pt)" --><p>
  152. <table class="mdTable" cellpadding="2" cellspacing="0">
  153. <tr>
  154. <td class="mdRow">
  155. <table cellpadding="0" cellspacing="0" border="0">
  156. <tr>
  157. <td class="md" nowrap valign="top">#define PT_EXIT </td>
  158. <td class="md" valign="top">(&nbsp;</td>
  159. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  160. <td class="mdname1" valign="top" nowrap> </td>
  161. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  162. <td class="md" nowrap></td>
  163. </tr>
  164. </table>
  165. </td>
  166. </tr>
  167. </table>
  168. <table cellspacing="5" cellpadding="0" border="0">
  169. <tr>
  170. <td>
  171. &nbsp;
  172. </td>
  173. <td>
  174. <p>
  175. Exit the protothread.
  176. <p>
  177. This 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>
  178. <dl compact><dt><b>Parameters:</b></dt><dd>
  179. <table border="0" cellspacing="2" cellpadding="0">
  180. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  181. </table>
  182. </dl>
  183. <p>
  184. Definition at line <a class="el" href="a00022.html#l00246">246</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  185. </tr>
  186. </table>
  187. <a class="anchor" name="ge6bae7dc0225468c8a5ac269df549892"></a><!-- doxytag: member="pt.h::PT_INIT" ref="ge6bae7dc0225468c8a5ac269df549892" args="(pt)" --><p>
  188. <table class="mdTable" cellpadding="2" cellspacing="0">
  189. <tr>
  190. <td class="mdRow">
  191. <table cellpadding="0" cellspacing="0" border="0">
  192. <tr>
  193. <td class="md" nowrap valign="top">#define PT_INIT </td>
  194. <td class="md" valign="top">(&nbsp;</td>
  195. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  196. <td class="mdname1" valign="top" nowrap> </td>
  197. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  198. <td class="md" nowrap></td>
  199. </tr>
  200. </table>
  201. </td>
  202. </tr>
  203. </table>
  204. <table cellspacing="5" cellpadding="0" border="0">
  205. <tr>
  206. <td>
  207. &nbsp;
  208. </td>
  209. <td>
  210. <p>
  211. Initialize a protothread.
  212. <p>
  213. Initializes a protothread. Initialization must be done prior to starting to execute the protothread.<p>
  214. <dl compact><dt><b>Parameters:</b></dt><dd>
  215. <table border="0" cellspacing="2" cellpadding="0">
  216. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure.</td></tr>
  217. </table>
  218. </dl>
  219. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00014.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN()</a> </dd></dl>
  220. <p>
  221. Definition at line <a class="el" href="a00022.html#l00080">80</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  222. </tr>
  223. </table>
  224. <a class="anchor" name="gcd3ac045f0a4ae63412e3b3d8780e8ab"></a><!-- doxytag: member="pt.h::PT_RESTART" ref="gcd3ac045f0a4ae63412e3b3d8780e8ab" args="(pt)" --><p>
  225. <table class="mdTable" cellpadding="2" cellspacing="0">
  226. <tr>
  227. <td class="mdRow">
  228. <table cellpadding="0" cellspacing="0" border="0">
  229. <tr>
  230. <td class="md" nowrap valign="top">#define PT_RESTART </td>
  231. <td class="md" valign="top">(&nbsp;</td>
  232. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  233. <td class="mdname1" valign="top" nowrap> </td>
  234. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  235. <td class="md" nowrap></td>
  236. </tr>
  237. </table>
  238. </td>
  239. </tr>
  240. </table>
  241. <table cellspacing="5" cellpadding="0" border="0">
  242. <tr>
  243. <td>
  244. &nbsp;
  245. </td>
  246. <td>
  247. <p>
  248. Restart the protothread.
  249. <p>
  250. This macro will block and cause the running protothread to restart its execution at the place of the <a class="el" href="a00014.html#g2ffbb9e554e08a343ae2f9de4bedfdfc">PT_BEGIN()</a> call.<p>
  251. <dl compact><dt><b>Parameters:</b></dt><dd>
  252. <table border="0" cellspacing="2" cellpadding="0">
  253. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  254. </table>
  255. </dl>
  256. <p>
  257. Definition at line <a class="el" href="a00022.html#l00229">229</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  258. </tr>
  259. </table>
  260. <a class="anchor" name="gfa82b860a64b67d25ab3abc21811896f"></a><!-- doxytag: member="pt.h::PT_SCHEDULE" ref="gfa82b860a64b67d25ab3abc21811896f" args="(f)" --><p>
  261. <table class="mdTable" cellpadding="2" cellspacing="0">
  262. <tr>
  263. <td class="mdRow">
  264. <table cellpadding="0" cellspacing="0" border="0">
  265. <tr>
  266. <td class="md" nowrap valign="top">#define PT_SCHEDULE </td>
  267. <td class="md" valign="top">(&nbsp;</td>
  268. <td class="md" nowrap valign="top">f&nbsp;</td>
  269. <td class="mdname1" valign="top" nowrap> </td>
  270. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  271. <td class="md" nowrap></td>
  272. </tr>
  273. </table>
  274. </td>
  275. </tr>
  276. </table>
  277. <table cellspacing="5" cellpadding="0" border="0">
  278. <tr>
  279. <td>
  280. &nbsp;
  281. </td>
  282. <td>
  283. <p>
  284. Schedule a protothread.
  285. <p>
  286. This 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>
  287. <dl compact><dt><b>Parameters:</b></dt><dd>
  288. <table border="0" cellspacing="2" cellpadding="0">
  289. <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>
  290. </table>
  291. </dl>
  292. <p>
  293. Definition at line <a class="el" href="a00022.html#l00271">271</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  294. </tr>
  295. </table>
  296. <a class="anchor" name="g9e97a0b4d5cc7764d8e19758f5da53ae"></a><!-- doxytag: member="pt.h::PT_SPAWN" ref="g9e97a0b4d5cc7764d8e19758f5da53ae" args="(pt, child, thread)" --><p>
  297. <table class="mdTable" cellpadding="2" cellspacing="0">
  298. <tr>
  299. <td class="mdRow">
  300. <table cellpadding="0" cellspacing="0" border="0">
  301. <tr>
  302. <td class="md" nowrap valign="top">#define PT_SPAWN </td>
  303. <td class="md" valign="top">(&nbsp;</td>
  304. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>, <tr>
  305. <td class="md" nowrap align="right"></td>
  306. <td class="md"></td>
  307. <td class="md" nowrap>child, <tr>
  308. <td class="md" nowrap align="right"></td>
  309. <td class="md"></td>
  310. <td class="md" nowrap>thread&nbsp;</td>
  311. <td class="mdname1" valign="top" nowrap> </td>
  312. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  313. <td class="md" nowrap></td>
  314. </tr>
  315. </table>
  316. </td>
  317. </tr>
  318. </table>
  319. <table cellspacing="5" cellpadding="0" border="0">
  320. <tr>
  321. <td>
  322. &nbsp;
  323. </td>
  324. <td>
  325. <p>
  326. Spawn a child protothread and wait until it exits.
  327. <p>
  328. This macro spawns a child protothread and waits until it exits. The macro can only be used within a protothread.<p>
  329. <dl compact><dt><b>Parameters:</b></dt><dd>
  330. <table border="0" cellspacing="2" cellpadding="0">
  331. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  332. <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>
  333. <tr><td valign="top"></td><td valign="top"><em>thread</em>&nbsp;</td><td>The child protothread with arguments </td></tr>
  334. </table>
  335. </dl>
  336. <p>
  337. Definition at line <a class="el" href="a00022.html#l00206">206</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  338. </tr>
  339. </table>
  340. <a class="anchor" name="g3d4c8bd4aada659eb34f5d2ffd3e7901"></a><!-- doxytag: member="pt.h::PT_THREAD" ref="g3d4c8bd4aada659eb34f5d2ffd3e7901" args="(name_args)" --><p>
  341. <table class="mdTable" cellpadding="2" cellspacing="0">
  342. <tr>
  343. <td class="mdRow">
  344. <table cellpadding="0" cellspacing="0" border="0">
  345. <tr>
  346. <td class="md" nowrap valign="top">#define PT_THREAD </td>
  347. <td class="md" valign="top">(&nbsp;</td>
  348. <td class="md" nowrap valign="top">name_args&nbsp;</td>
  349. <td class="mdname1" valign="top" nowrap> </td>
  350. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  351. <td class="md" nowrap></td>
  352. </tr>
  353. </table>
  354. </td>
  355. </tr>
  356. </table>
  357. <table cellspacing="5" cellpadding="0" border="0">
  358. <tr>
  359. <td>
  360. &nbsp;
  361. </td>
  362. <td>
  363. <p>
  364. Declaration of a protothread.
  365. <p>
  366. This macro is used to declare a protothread. All protothreads must be declared with this macro.<p>
  367. <dl compact><dt><b>Parameters:</b></dt><dd>
  368. <table border="0" cellspacing="2" cellpadding="0">
  369. <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>
  370. </table>
  371. </dl>
  372. <p>
  373. Definition at line <a class="el" href="a00022.html#l00100">100</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  374. </tr>
  375. </table>
  376. <a class="anchor" name="g2f8f70c30b9ee08a103fbd69a4365c4c"></a><!-- doxytag: member="pt.h::PT_WAIT_THREAD" ref="g2f8f70c30b9ee08a103fbd69a4365c4c" args="(pt, thread)" --><p>
  377. <table class="mdTable" cellpadding="2" cellspacing="0">
  378. <tr>
  379. <td class="mdRow">
  380. <table cellpadding="0" cellspacing="0" border="0">
  381. <tr>
  382. <td class="md" nowrap valign="top">#define PT_WAIT_THREAD </td>
  383. <td class="md" valign="top">(&nbsp;</td>
  384. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>, <tr>
  385. <td class="md" nowrap align="right"></td>
  386. <td class="md"></td>
  387. <td class="md" nowrap>thread&nbsp;</td>
  388. <td class="mdname1" valign="top" nowrap> </td>
  389. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  390. <td class="md" nowrap></td>
  391. </tr>
  392. </table>
  393. </td>
  394. </tr>
  395. </table>
  396. <table cellspacing="5" cellpadding="0" border="0">
  397. <tr>
  398. <td>
  399. &nbsp;
  400. </td>
  401. <td>
  402. <p>
  403. Block and wait until a child protothread completes.
  404. <p>
  405. This macro schedules a child protothread. The current protothread will block until the child protothread completes.<p>
  406. <dl compact><dt><b>Note:</b></dt><dd>The child protothread must be manually initialized with the <a class="el" href="a00014.html#ge6bae7dc0225468c8a5ac269df549892">PT_INIT()</a> function before this function is used.</dd></dl>
  407. <dl compact><dt><b>Parameters:</b></dt><dd>
  408. <table border="0" cellspacing="2" cellpadding="0">
  409. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  410. <tr><td valign="top"></td><td valign="top"><em>thread</em>&nbsp;</td><td>The child protothread with arguments</td></tr>
  411. </table>
  412. </dl>
  413. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00014.html#g9e97a0b4d5cc7764d8e19758f5da53ae">PT_SPAWN()</a> </dd></dl>
  414. <p>
  415. Definition at line <a class="el" href="a00022.html#l00192">192</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  416. </tr>
  417. </table>
  418. <a class="anchor" name="g99e43010ec61327164466aa2d902de45"></a><!-- doxytag: member="pt.h::PT_WAIT_UNTIL" ref="g99e43010ec61327164466aa2d902de45" args="(pt, condition)" --><p>
  419. <table class="mdTable" cellpadding="2" cellspacing="0">
  420. <tr>
  421. <td class="mdRow">
  422. <table cellpadding="0" cellspacing="0" border="0">
  423. <tr>
  424. <td class="md" nowrap valign="top">#define PT_WAIT_UNTIL </td>
  425. <td class="md" valign="top">(&nbsp;</td>
  426. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>, <tr>
  427. <td class="md" nowrap align="right"></td>
  428. <td class="md"></td>
  429. <td class="md" nowrap>condition&nbsp;</td>
  430. <td class="mdname1" valign="top" nowrap> </td>
  431. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  432. <td class="md" nowrap></td>
  433. </tr>
  434. </table>
  435. </td>
  436. </tr>
  437. </table>
  438. <table cellspacing="5" cellpadding="0" border="0">
  439. <tr>
  440. <td>
  441. &nbsp;
  442. </td>
  443. <td>
  444. <p>
  445. Block and wait until condition is true.
  446. <p>
  447. This macro blocks the protothread until the specified condition is true.<p>
  448. <dl compact><dt><b>Parameters:</b></dt><dd>
  449. <table border="0" cellspacing="2" cellpadding="0">
  450. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  451. <tr><td valign="top"></td><td valign="top"><em>condition</em>&nbsp;</td><td>The condition. </td></tr>
  452. </table>
  453. </dl>
  454. <p>
  455. Definition at line <a class="el" href="a00022.html#l00148">148</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  456. </tr>
  457. </table>
  458. <a class="anchor" name="gad14bbbf092b90aa0a5a4f9169504a8d"></a><!-- doxytag: member="pt.h::PT_WAIT_WHILE" ref="gad14bbbf092b90aa0a5a4f9169504a8d" args="(pt, cond)" --><p>
  459. <table class="mdTable" cellpadding="2" cellspacing="0">
  460. <tr>
  461. <td class="mdRow">
  462. <table cellpadding="0" cellspacing="0" border="0">
  463. <tr>
  464. <td class="md" nowrap valign="top">#define PT_WAIT_WHILE </td>
  465. <td class="md" valign="top">(&nbsp;</td>
  466. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>, <tr>
  467. <td class="md" nowrap align="right"></td>
  468. <td class="md"></td>
  469. <td class="md" nowrap>cond&nbsp;</td>
  470. <td class="mdname1" valign="top" nowrap> </td>
  471. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  472. <td class="md" nowrap></td>
  473. </tr>
  474. </table>
  475. </td>
  476. </tr>
  477. </table>
  478. <table cellspacing="5" cellpadding="0" border="0">
  479. <tr>
  480. <td>
  481. &nbsp;
  482. </td>
  483. <td>
  484. <p>
  485. Block and wait while condition is true.
  486. <p>
  487. This function blocks and waits while condition is true. See <a class="el" href="a00014.html#g99e43010ec61327164466aa2d902de45">PT_WAIT_UNTIL()</a>.<p>
  488. <dl compact><dt><b>Parameters:</b></dt><dd>
  489. <table border="0" cellspacing="2" cellpadding="0">
  490. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  491. <tr><td valign="top"></td><td valign="top"><em>cond</em>&nbsp;</td><td>The condition. </td></tr>
  492. </table>
  493. </dl>
  494. <p>
  495. Definition at line <a class="el" href="a00022.html#l00167">167</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  496. </tr>
  497. </table>
  498. <a class="anchor" name="g155cba6121323726d02c00284428fed6"></a><!-- doxytag: member="pt.h::PT_YIELD" ref="g155cba6121323726d02c00284428fed6" args="(pt)" --><p>
  499. <table class="mdTable" cellpadding="2" cellspacing="0">
  500. <tr>
  501. <td class="mdRow">
  502. <table cellpadding="0" cellspacing="0" border="0">
  503. <tr>
  504. <td class="md" nowrap valign="top">#define PT_YIELD </td>
  505. <td class="md" valign="top">(&nbsp;</td>
  506. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>&nbsp;</td>
  507. <td class="mdname1" valign="top" nowrap> </td>
  508. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  509. <td class="md" nowrap></td>
  510. </tr>
  511. </table>
  512. </td>
  513. </tr>
  514. </table>
  515. <table cellspacing="5" cellpadding="0" border="0">
  516. <tr>
  517. <td>
  518. &nbsp;
  519. </td>
  520. <td>
  521. <p>
  522. Yield from the current protothread.
  523. <p>
  524. This function will yield the protothread, thereby allowing other processing to take place in the system.<p>
  525. <dl compact><dt><b>Parameters:</b></dt><dd>
  526. <table border="0" cellspacing="2" cellpadding="0">
  527. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  528. </table>
  529. </dl>
  530. <p>
  531. Definition at line <a class="el" href="a00022.html#l00290">290</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  532. </tr>
  533. </table>
  534. <a class="anchor" name="ge3c821e3a388615528efda9d23c7d115"></a><!-- doxytag: member="pt.h::PT_YIELD_UNTIL" ref="ge3c821e3a388615528efda9d23c7d115" args="(pt, cond)" --><p>
  535. <table class="mdTable" cellpadding="2" cellspacing="0">
  536. <tr>
  537. <td class="mdRow">
  538. <table cellpadding="0" cellspacing="0" border="0">
  539. <tr>
  540. <td class="md" nowrap valign="top">#define PT_YIELD_UNTIL </td>
  541. <td class="md" valign="top">(&nbsp;</td>
  542. <td class="md" nowrap valign="top"><a class="el" href="a00005.html">pt</a>, <tr>
  543. <td class="md" nowrap align="right"></td>
  544. <td class="md"></td>
  545. <td class="md" nowrap>cond&nbsp;</td>
  546. <td class="mdname1" valign="top" nowrap> </td>
  547. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  548. <td class="md" nowrap></td>
  549. </tr>
  550. </table>
  551. </td>
  552. </tr>
  553. </table>
  554. <table cellspacing="5" cellpadding="0" border="0">
  555. <tr>
  556. <td>
  557. &nbsp;
  558. </td>
  559. <td>
  560. <p>
  561. Yield from the protothread until a condition occurs.
  562. <p>
  563. <dl compact><dt><b>Parameters:</b></dt><dd>
  564. <table border="0" cellspacing="2" cellpadding="0">
  565. <tr><td valign="top"></td><td valign="top"><em>pt</em>&nbsp;</td><td>A pointer to the protothread control structure. </td></tr>
  566. <tr><td valign="top"></td><td valign="top"><em>cond</em>&nbsp;</td><td>The condition.</td></tr>
  567. </table>
  568. </dl>
  569. This function will yield the protothread, until the specified condition evaluates to true.
  570. <p>
  571. Definition at line <a class="el" href="a00022.html#l00310">310</a> of file <a class="el" href="a00022.html">pt.h</a>. </td>
  572. </tr>
  573. </table>
  574. <hr size="1"><address style="align: right;"><small>Generated on Mon Oct 2 10:06:29 2006 for The Protothreads Library 1.4 by&nbsp;
  575. <a href="http://www.doxygen.org/index.html">
  576. <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
  577. </body>
  578. </html>