File syn_barrier.h¶
FileList > common > syn_barrier.h
Go to the source code of this file
Memory ordering primitives for cross-core and ISR safety. More...
#include "syn_compiler.h"#include <stddef.h>
Public Static Functions¶
| Type | Name |
|---|---|
| size_t | syn_load_acquire (const volatile size_t * ptr) Load with acquire semantics (single-core path). |
| void | syn_store_release (volatile size_t * ptr, size_t val) Store with release semantics (single-core path). |
Macros¶
| Type | Name |
|---|---|
| define | SYN_LOAD_ACQUIRE (ptr) [**syn\_load\_acquire**](syn__barrier_8h.md#function-syn_load_acquire)((ptr))Load with acquire semantics (macro form). |
| define | SYN_STORE_RELEASE (ptr, val) [**syn\_store\_release**](syn__barrier_8h.md#function-syn_store_release)((ptr), (val))Store with release semantics (macro form). |
Detailed Description¶
Provides acquire/release semantics for lock-free data structures that are shared between CPU cores (AMP multicore) or between ISR and main context.
** **
When SYN_USE_MULTICORE is off (the default), the acquire/release functions compile to plain volatile reads and writes — identical to what the code would do without barriers. Zero overhead.
When SYN_USE_MULTICORE is on, the functions insert hardware memory barriers (via syn_port_memory_barrier()) at the correct points to ensure cross-core visibility.
** **
- STORE_RELEASE: All prior writes are visible before this store. Use after writing data, before publishing the index.
- LOAD_ACQUIRE: No subsequent reads can be reordered before this load. Use after reading an index, before accessing the data it guards.
** **
// Producer (core 0):
buf[head] = data;
SYN_STORE_RELEASE(&rb->head, next_head);
// Consumer (core 1):
size_t h = SYN_LOAD_ACQUIRE(&rb->head);
if (h != tail) {
x = buf[tail]; // guaranteed to see data written before head
}
Public Static Functions Documentation¶
function syn_load_acquire¶
Load with acquire semantics (single-core path).
On single-core targets, volatile access is sufficient. This compiles to a plain load — zero overhead.
Parameters:
ptrPointer to volatile size_t.
Returns:
The loaded value.
function syn_store_release¶
Store with release semantics (single-core path).
On single-core targets, volatile access is sufficient because interrupts imply a full pipeline flush. This compiles to a plain store — zero overhead.
Parameters:
ptrPointer to volatile size_t.valValue to store.
Macro Definition Documentation¶
define SYN_LOAD_ACQUIRE¶
Load with acquire semantics (macro form).
define SYN_STORE_RELEASE¶
Store with release semantics (macro form).
The documentation for this class was generated from the following file src/syntropic/common/syn_barrier.h