ARM 单拷贝原子性 [英] ARM single-copy atomicity

查看:34
本文介绍了ARM 单拷贝原子性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在浏览 ARMv7 内核的 ARM 架构手册.在关于内存访问原子性的章节 A3.5.3 中,它指出:

I am currently wading through the ARM architecture manual for the ARMv7 core. In chapter A3.5.3 about atomicity of memory accesses, it states:

如果单拷贝原子加载与单拷贝原子存储重叠并且对于任何重叠字节,负载返回写入的数据写入插入到该字节的 Coherence 顺序中单拷贝原子存储然后加载必须从一个点返回数据在 Coherence 顺序中不早于插入到所有数据的单副本原子存储的一致性顺序重叠字节.

If a single-copy atomic load overlaps a single-copy atomic store and for any of the overlapping bytes the load returns the data written by the write inserted into the Coherence order of that byte by the single-copy atomic store then the load must return data from a point in the Coherence order no earlier than the writes inserted into the Coherence order by the single-copy atomic store of all of the overlapping bytes.

作为非英语母语者,我承认我在理解这句话时有点困难.

As non-native english speaker I admit that I am slightly challenged in understanding this sentence.

是否存在写入内存字节未插入到 Coherence Order 中,因此上述情况不适用的情况?如果不是,我是否正确地说将句子缩短和改写为以下内容:

Is there a scenario where writes to a memory byte are not inserted in the Coherence Order and thus the above does not apply? If not, am I correct to say that shortening and rephrasing the sentence to the following:

如果加载恰好返回了至少一个字节的写入,然后加载必须从一个点返回所有重叠的字节不早于写入将它们插入到所有重叠字节的连贯顺序.

If the load happens to return at least one byte of the the write, then the load must return all overlapping bytes from a point no earlier than where the write inserted them into the Coherence order of all of the overlapping bytes.

仍然传输相同的含义?

推荐答案

我在 ARMv8 ARM 中看到了这样的措辞,它确实试图消除很多地方的任何可能的歧义(即使它确实使内存排序部分实际上不可读).

I see that wording in the ARMv8 ARM, which really tries to remove any possible ambiguity in a lot of places (even if it does make the memory ordering section virtually unreadable).

就一般理解而言(与实际实施规范相反),一点点歧义并不总是有害,因此虽然它不能绝对em> 清楚内存位置"的含义,我认为在这种情况下,旧的 v7 手册 (DDI0406C.b) 更适合阅读:

In terms of general understanding (as opposed to to actually implementing the specification), a little bit of ambiguity doesn't always hurt, so whilst it fails to make it absolutely clear what a "memory location" means, I think the old v7 manual (DDI0406C.b) is a nicer read in this case:

如果以下条件都为真,则读取或写入操作是单副本原子操作:

A read or write operation is single-copy atomic if the following conditions are both true:

  • 对某个内存位置进行任意次数的写操作后,该内存位置的值就是其中一次写操作写入的值.内存位置的一部分值不可能来自一次写操作而另一部分值来自不同的写操作

  • After any number of write operations to a memory location, the value of the memory location is the value written by one of the write operations. It is impossible for part of the value of the memory location to come from one write operation and another part of the value to come from a different write operation

当对同一个内存位置进行读操作和写操作时,读操作得到的值为以下之一:

When a read operation and a write operation are made to the same memory location, the value obtained by the read operation is one of:

  • 写操作前内存位置的值
  • 写入操作后内存位置的值.

永远不会出现读操作的值部分是写操作前的内存位置值,部分是写操作后的内存位置值的情况.

It is never the case that the value of the read operation is partly the value of the memory location before the write operation and partly the value of the memory location after the write operation.

所以你的理解是正确的 - 单拷贝原子操作的定义点是在任何给定的时间你只能看到全部> 它.

So your understanding is right - the defining point of a single-copy atomic operation is that at any given time you can only ever see either all of it, or none of it.

在 v7 中有一种情况(如果我的解释正确的话)同时出现在同一位置但大小不同的两个通常单拷贝的原子存储破坏了原子性的任何保证,所以理论上你可以在那里观察到一些意想不到的字节组合 - 这似乎已在 v8 中删除.

There is a case in v7 whereby (if I'm interpreting it right) two normally single-copy atomic stores that occur to the same location at the same time but with different sizes break any guarantee of atomicity, so in theory you could observe some unexpected mix of bytes there - this looks to have been removed in v8.

这篇关于ARM 单拷贝原子性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆