Parallel Programming Guide for HP-UX Systems

Parallel synchronization
Synchronization tools
Chapter 8146
The forms of these directives and pragmas are shown in Table 8-8.
where
gate
is an optional gate variable used for access to the
critical section.
gate
must be appropriately declared as
described in the “Using gates and barriers” on
page 136.
The gate variable is required when synchronizing access to a shared
variable from multiple parallel tasks.
When a gate variable is specified, it must be allocated (using the
alloc_gate intrinsic) outside of parallel code prior to use
If no gate is specified, the compiler creates a unique gate for the
critical section
When a gate is no longer needed, it should be deallocated using the
free_gate function.
NOTE Critical sections add synchronization overhead to your
program. They should only be used when the amount of
parallel code is significantly larger than the amount of
code containing the dependence.
Table 8-8 Forms of critical_section, end_critical_section
directives and pragmas
Language Form
Fortran C$DIR CRITICAL_SECTION[(gate)]
...
C$DIR END_CRITICAL_SECTION
C #pragma _CNX
critical_section[(gate)] ...#pragma
_CNX end_critical_section