Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This thread pauses execution using cnd_wait() and resumes when notified, presumably when the list has elements to be consumed. It is possible for the thread to be notified even if the list is still empty, perhaps because the notifying thread used cnd_broadcast(), which notifies all threads. This is usually preferred; see CON38-C. Notify all threads waiting on a condition variablePreserve thread-safety and liveness when using condition variables for more information.

Note that a condition predicate is typically the negation of the condition expression in the loop. In this noncompliant code example, the condition predicate for removing an element from a linked list is (list->next != NULL), whereas the condition expression for the while loop condition is (list->next == NULL).

...

[ISO/IEC 9899:2011]Subclause 7.17.7.4, "The atomic_compare_exchange Generic Functions"

[Lea 2000]

1.3.2, "Liveness"
3.2.2, "Monitor Mechanics"

 Image Removed Image Removed Image Removed

...

Image Added Image Added Image Added