XWOS API
4.0
XWOS C/C++ API参考手册
|
宏定义 | |
#define | xwmb_access(t, v) (*((volatile t *)&(v))) |
: 强制从内存中访问指定类型的变量 | |
#define | xwmb_read(t, v, p) xwmb_access(t, v) = (*(volatile t * )(p)) |
: 读取地址中的指定类型的值 | |
#define | xwmb_write(t, p, v) (*(volatile t * )(p)) = (v) |
存储指定类型的值到地址中 | |
#define | xwmb_compiler() |
编译器内存屏障 | |
#define | xwmb_mp_mb() |
多核系统内存屏障 | |
#define | xwmb_mp_rmb() |
多核系统读内存屏障 | |
#define | xwmb_mp_wmb() |
多核写内存屏障 | |
#define | xwmb_ddb() xwmb_compiler() |
数据依赖屏障 @detail | |
#define | xwmb_mp_consume() xwmb_ddb() |
多核系统 消费 屏障,数据依赖屏障 | |
#define | xwmb_mp_acquire() xwmb_mp_mb() |
多核系统 获取 屏障 | |
#define | xwmb_mp_release() xwmb_mp_mb() |
多核系统 释放 屏障 | |
#define | xwmb_mp_load_acquire(t, v, p) |
: 读取地址中的指定类型的值,并保证此处的“读”操作一定发生在之后的“读写”操作之前 | |
#define | xwmb_mp_store_release(t, p, v) |
存储指定类型的值到地址中,并保证此处的“写”操作一定发生在之前的“读写”操作之后 | |
#define xwmb_access | ( | t, | |
v | |||
) | (*((volatile t *)&(v))) |
#define xwmb_ddb | ( | ) | xwmb_compiler() |
数据依赖屏障 @detail
same as mp_read_barrier_depends()
in Linux. (From Linux kernel): No data-dependent reads from memory-like regions are ever reordered over this barrier. All reads preceding this primitive are guaranteed to access memory (but not necessarily other CPUs' caches) before any reads following this primitive that depend on the data return by any of the preceding reads. This primitive is much lighter weight than rmb()
on most CPUs, and is never heavier weight than is rmb()
.
These ordering constraints are respected by both the local CPU and the compiler.
Ordering is not guaranteed by anything other than these primitives, not even by data dependencies. See the documentation for memory_barrier()
for examples and URLs to more information.
For example, the following code would force ordering (the initial value of "a" is zero, "b" is one, and "p" is "&a"):
because the read of "*q" depends on the read of "p" and these two reads are separated by a read_barrier_depends(). However, the following code, with the same initial values for "a" and "b":
does not enforce ordering, since there is no data dependency between the read of "a" and the read of "b". Therefore, on some CPUs, such as Alpha, "y" could be set to 3 and "x" to 0. Use rmb() in cases like this where there are no data dependencies.
memory_order_consume
)所表达的意思也即是读依赖屏障。#define xwmb_mp_acquire | ( | ) | xwmb_mp_mb() |
#define xwmb_mp_load_acquire | ( | t, | |
v, | |||
p | |||
) |
#define xwmb_mp_release | ( | ) | xwmb_mp_mb() |
#define xwmb_mp_store_release | ( | t, | |
p, | |||
v | |||
) |
#define xwmb_read | ( | t, | |
v, | |||
p | |||
) | xwmb_access(t, v) = (*(volatile t * )(p)) |