mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-04 05:41:33 +01:00
25 lines
1.1 KiB
TeX
25 lines
1.1 KiB
TeX
\subsection{Ownership of Locks}
|
|
\label{subsec:lock_owner}
|
|
|
|
\index{routines!omp_unset_lock@\kcode{omp_unset_lock}}
|
|
\index{omp_unset_lock routine@\kcode{omp_unset_lock} routine}
|
|
Ownership of locks has changed since OpenMP 2.5. In OpenMP 2.5, locks are owned
|
|
by threads; so a lock released by the \kcode{omp_unset_lock} routine must be
|
|
owned by the same thread executing the routine. Beginning with OpenMP 3.0, locks are owned
|
|
by tasks; so a lock released by the \kcode{omp_unset_lock} routine in
|
|
a task must be owned by the same task.
|
|
|
|
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 \ucode{lck}
|
|
in the \kcode{parallel} region is the same thread that acquired the lock in the sequential
|
|
part of the program (primary thread of \kcode{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 \ucode{lck} is different from the task region that
|
|
acquires the lock.
|
|
|
|
\cexample[5.1]{lock_owner}{1}
|
|
|
|
\fexample[5.1]{lock_owner}{1}
|
|
|
|
|