mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-24 14:51:25 +01:00
22 lines
978 B
TeX
22 lines
978 B
TeX
\pagebreak
|
|
\section{Worksharing Constructs Inside a \code{critical} Construct}
|
|
\label{sec:worksharing_critical}
|
|
\index{constructs!worksharing}
|
|
\index{constructs!critical@\code{critical}}
|
|
\index{critical construct@\code{critical} construct}
|
|
|
|
The following example demonstrates using a worksharing construct inside a \code{critical}
|
|
construct. This example is conforming because the worksharing \code{single}
|
|
region is not closely nested inside the \code{critical} region. A single thread
|
|
executes the one and only section in the \code{sections} region, and executes
|
|
the \code{critical} region. The same thread encounters the nested \code{parallel}
|
|
region, creates a new team of threads, and becomes the primary thread of the new team.
|
|
One of the threads in the new team enters the \code{single} region and increments
|
|
\code{i} by \code{1}. At the end of this example \code{i} is equal to \code{2}.
|
|
|
|
\cexample{worksharing_critical}{1}
|
|
|
|
\fexample{worksharing_critical}{1}
|
|
|
|
|