2024-04-16 08:59:23 -07:00

26 lines
996 B
TeX

%\pagebreak
\section{\kcode{critical} Construct}
\label{sec:critical}
\index{constructs!critical@\kcode{critical}}
\index{critical construct@\kcode{critical} construct}
\index{critical construct@\kcode{critical} construct!hint clause@\kcode{hint} clause}
\index{clauses!hint@\kcode{hint}}
\index{hint clause@\kcode{hint} clause}
The following example includes several \kcode{critical} constructs. The example
illustrates a queuing model in which a task is dequeued and worked on. To guard
against multiple threads dequeuing the same task, the dequeuing operation must
be in a \kcode{critical} region. Because the two queues in this example are independent,
they are protected by \kcode{critical} constructs with different names, \ucode{xaxis}
and \ucode{yaxis}.
\cexample{critical}{1}
\fexample{critical}{1}
The following example extends the previous example by adding the \kcode{hint} clause to the \kcode{critical} constructs.
\cexample[5.0]{critical}{2}
\fexample[5.0]{critical}{2}