mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-10 16:32:11 +01:00
23 lines
1019 B
TeX
23 lines
1019 B
TeX
\subsection{Ownership of Locks}
|
|
\label{subsec:lock_owner}
|
|
|
|
Ownership of locks has changed since OpenMP 2.5. In OpenMP 2.5, locks are owned
|
|
by threads; so a lock released by the \code{omp\_unset\_lock} routine must be
|
|
owned by the same thread executing the routine. Beginning with OpenMP 3.0, locks are owned
|
|
by task regions; so a lock released by the \code{omp\_unset\_lock} routine in
|
|
a task region must be owned by the same task region.
|
|
|
|
This change in ownership requires extra care when using locks. The following program
|
|
is conforming in OpenMP 2.5 because the thread that releases the lock \code{lck}
|
|
in the parallel region is the same thread that acquired the lock in the sequential
|
|
part of the program (master thread of parallel region and the initial thread are
|
|
the same). However, it is not conforming beginning with OpenMP 3.0, because the task
|
|
region that releases the lock \code{lck} is different from the task region that
|
|
acquires the lock.
|
|
|
|
\cexample{lock_owner}{1}
|
|
|
|
\fexample{lock_owner}{1}
|
|
|
|
|