小编ara*_*esc的帖子

x86可以重新排序一个具有更宽负载的窄存储吗?

英特尔®64和IA-32架构软件开发人员手册说:

8.2.3.4负载可以通过早期存储
重新排序到不同位置 Intel-64内存排序模型允许将负载与早期存储重新排序到不同位置.但是,加载不会与商店重新排序到同一位置.

那些与之前的商店部分或完全重叠但是没有相同起始地址的负载呢?(有关具体案例,请参阅本文末尾)


假设以下类似C的代码:

// lock - pointer to an aligned int64 variable
// threadNum - integer in the range 0..7
// volatiles here just to show direct r/w of the memory as it was suggested in the comments
int TryLock(volatile INT64* lock, INT64 threadNum)
{
    if (0 != *lock)
        return 0;                           // another thread already had the lock

    ((volatile INT8*)lock)[threadNum] = 1;  // take the lock by setting our byte

    if (1LL << 8*threadNum != …
Run Code Online (Sandbox Code Playgroud)

x86 assembly multithreading locking x86-64

10
推荐指数
2
解决办法
694
查看次数

标签 统计

assembly ×1

locking ×1

multithreading ×1

x86 ×1

x86-64 ×1