mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
20 lines
637 B
TeX
20 lines
637 B
TeX
\pagebreak
|
|
\chapter{Simple Lock Routines}
|
|
\label{chap: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 \code{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 \code{omp\_lock\_t},
|
|
and that there is no need to flush it.
|
|
|
|
\cexample{simple_lock}{1c}
|
|
|
|
Note that there is no need to flush the lock variable.
|
|
|
|
\fexample{simple_lock}{1f}
|
|
|
|
|