mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-10 16:32:11 +01:00
19 lines
836 B
TeX
19 lines
836 B
TeX
\pagebreak
|
|
\section{The \code{firstprivate} Clause and the \code{sections} Construct}
|
|
\label{sec:fpriv_sections}
|
|
|
|
In the following example of the \code{sections} construct the \code{firstprivate}
|
|
clause is used to initialize the private copy of \code{section\_count} of each
|
|
thread. The problem is that the \code{section} constructs modify \code{section\_count},
|
|
which breaks the independence of the \code{section} constructs. When different
|
|
threads execute each section, both sections will print the value 1. When the same
|
|
thread executes the two sections, one section will print the value 1 and the other
|
|
will print the value 2. Since the order of execution of the two sections in this
|
|
case is unspecified, it is unspecified which section prints which value.
|
|
|
|
\cexample{fpriv_sections}{1}
|
|
|
|
\ffreeexample{fpriv_sections}{1}
|
|
|
|
|