forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Examples_lock_owner.tex
23 lines (17 loc) · 1 KB
/
Examples_lock_owner.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\pagebreak
\chapter{Ownership of Locks}
\label{chap: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}{1c}
\fexample{lock_owner}{1f}