#pragma omp critical Preprocessor Directive (C only)

The omp critical directive identifies a section of code that must be executed by a single thread at a time.

Syntax

#pragma omp critical [(name)]
   statement_block

where name can optionally be used to identify the critical region. Identifiers naming a critical region have external linkage and occupy a namespace distinct from that used by ordinary identifiers.

Notes
A thread waits at the start of a critical region identified by a given name until no other thread in the program is executing a critical region with that same name. Critical sections not specifically named by omp critical directive invocation are mapped to the same unspecified name.



Program Parallelization
Shared and Private Variables in a Parallel Environment
Countable Loops


Control Parallel Processing with Pragmas


#pragma Preprocessor Directives for Parallel Processing
OpenMP Run-time Options for Parallel Processing