mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-23 22:31:22 +01:00
18 lines
636 B
TeX
18 lines
636 B
TeX
\subsection{Simple Lock Routines}
|
|
\label{subsec:simple_lock}
|
|
|
|
In the following example, the lock routines cause the threads to be idle while
|
|
waiting for entry to the first critical section, but to do other work while waiting
|
|
for entry to the second. The \code{omp\_set\_lock} function blocks, but the \scode{omp_test_lock}
|
|
function does not, allowing the work in \code{skip} to be done.
|
|
|
|
Note that the argument to the lock routines should have type
|
|
\scode{omp_lock_t} (or \scode{omp_lock_kind} in Fortran),
|
|
and that there is no need to flush the lock variable (\plc{lck}).
|
|
|
|
\cexample{simple_lock}{1}
|
|
|
|
\fexample{simple_lock}{1}
|
|
|
|
|