Subversion Repositories HelenOS-doc

Rev

Rev 86 | Rev 131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86 Rev 102
Line 334... Line 334...
334
      <example>
334
      <example>
335
        <title>Use of <code>condvar_wait_timeout()</code>.</title>
335
        <title>Use of <code>condvar_wait_timeout()</code>.</title>
336
 
336
 
337
        <programlisting language="C"><function>mutex_lock</function>(<varname>mtx</varname>);
337
        <programlisting language="C"><function>mutex_lock</function>(<varname>mtx</varname>);
338
while (!<varname>condition</varname>)
338
while (!<varname>condition</varname>)
339
        <function>condvar_wait_timeout</function>(<varname>cv</varname>, <varname>mtx</varname>);
339
        <function>condvar_wait_timeout</function>(<varname>cv</varname>, <varname>mtx</varname>); /* <remark>the condition is true, do something</remark> */
340
/* <remark>the condition is true, do something</remark> */
-
 
341
<function>mutex_unlock</function>(<varname>mtx</varname>);</programlisting>
340
<function>mutex_unlock</function>(<varname>mtx</varname>);</programlisting>
342
      </example>
341
      </example>
343
 
342
 
344
      <para>A thread that causes the condition become true signals this event
343
      <para>A thread that causes the condition become true signals this event
345
      like this:</para>
344
      like this:</para>
346
 
345
 
347
      <example>
346
      <example>
348
        <title>Use of <code>condvar_signal</code>.</title>
347
        <title>Use of <code>condvar_signal</code>.</title>
349
 
348
 
350
        <programlisting><function>mutex_lock</function>(<varname>mtx</varname>);
349
        <programlisting language="C"><function>mutex_lock</function>(<varname>mtx</varname>);
351
<varname>condition</varname> = <constant>true</constant>;
350
<varname>condition</varname> = <constant>true</constant>;
352
<function>condvar_signal</function>(<varname>cv</varname>);  /* <remark>condvar_broadcast(cv);</remark> */
351
<function>condvar_signal</function>(<varname>cv</varname>);  /* <remark>condvar_broadcast(cv);</remark> */
353
<function>mutex_unlock</function>(<varname>mtx</varname>);</programlisting>
352
<function>mutex_unlock</function>(<varname>mtx</varname>);</programlisting>
354
      </example>
353
      </example>
355
 
354