atomics and operators

suggest change

Atomic variables can be accessed concurrently between different threads without creating race conditions.

/* a global static variable that is visible by all threads */
static unsigned _Atomic active = ATOMIC_VAR_INIT(0);
int myThread(void* a) {
  ++active;         // increment active race free
  // do something
  --active;         // decrement active race free
  return 0;

All lvalue operations (operations that modify the object) that are allowed for the base type are allowed and will not lead to race conditions between different threads that access them.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents