#pragma omp critical

Description

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

Syntax

Read syntax diagramSkip visual syntax diagram                            .-,------.
                            V        |
>>-#--pragma--omp critical----(name)-+-------------------------><

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.