meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
programming:c:atomic [2024/11/27 17:30] niziakprogramming:c:atomic [2025/02/03 08:42] (current) niziak
Line 8: Line 8:
 > It is used to provide synchronization within threads in programs. Unlike ''atomic_bool'', > It is used to provide synchronization within threads in programs. Unlike ''atomic_bool'',
 > ''atomic_flag'' does not provide load or store operations. > ''atomic_flag'' does not provide load or store operations.
- 
  
 [[https://en.cppreference.com/w/c/atomic/atomic_flag|atomic_flag]] [[https://en.cppreference.com/w/c/atomic/atomic_flag|atomic_flag]]
 +
 +
 +<code c>
 +#include <stdatomic.h>
 +
 +atomic_flag busy;
 +
 +if (atomic_flag_test_and_set(&busy) {
 +    return APP_ERR_BUSY;
 +}
 +...
 +atomic_flag_clear(&busy);
 +</code>
  
 ===== atomic vars ===== ===== atomic vars =====