gpt4 book ai didi

assembly - 加载-获取/存储-释放和中断

转载 作者:行者123 更新时间:2023-12-02 22:17:44 25 4
gpt4 key购买 nike

假设我有一个原子加载-修改-存储操作:

1:    ldaxr x8, [x9]
orr x10, x8, #1
stlxr w11, x10, [x9]
cbnz w11, 1b

如果我理解正确的话,当这段代码在两个核心上执行时(访问相同的内存地址),那么线程A会使用ldaxr锁定资源。线程 B 中的 STLxr 失败并重试操作,直到线程 A 释放锁。

但是,如果主线程中的 ldaxr 之后发生中断并且中断处理程序尝试访问相同的内存地址,会发生什么情况?是否会出现死锁或中断处理程序优先,并且主线程中的 STLxr 从中断返回时会失败?

最佳答案

主线程中的STLxr将会失败。
ldaxrSTLxrLoad-link/Store-conditional说明,它们是无锁的,用户必须准备好重复 LL/SC。

Whenever an address is read using a Load Exclusive instruction, it is marked as being for an exclusive access. If an address marked as exclusive is written to using a Store Exclusive instruction, it clears the exclusive status. An attempt to write to an address not marked as exclusive using a Store Exclusive instruction will not succeed. This enables software to detect if the contents of that address have been changed since the last time it was read.

关于assembly - 加载-获取/存储-释放和中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57945679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com