理解MIPS指令集中的ll(loadlinked)和sc(storeconditional)指令

更新时间:2023-06-11 02:25:33 阅读: 评论:0

凉拌八爪鱼
理解MIPS指令集中的ll(loadlinked)和sc(storeconditional)指令
关于MIPS指令集的ll(load linked)和sc(store conditional)指令,课本上的叙述实在不好理解(于我)驾照扣分
所以找了⼀个⽐较好理解的版本记录下来。
婚假怎么休
塔伊普Q:What is ll and sc in mips?
如何停用朋友圈
A:Load linked (LL) and store conditional (SC) instructions are a way to achieve atomic memory >updates in shared memory multiprocessor systems, without locking memory locations for >exclusive access by one processor.
李秘书The idea is that you u LL to load the value stored at a memory location into a register, modify >it however you like there, and subquently write it back to the same place using SC. SC will only >overwrite the value in memory with your modified one if no other processor has altered it while >you were working on the copy in the register. It has the side-effect of tting a status flag to >indicate whether or not it was successful.
五指山图片When the updated value is successfully stored, a thread can trust that its read-modify-write >quence was completed without interference from other threads. On a failure, it is up to the >program to decide
whether to give up or reload the address and try again, but at least it doesn’t >produce an undetected Race condition.
英⽂部分转⾃
拙劣的翻译:
ll和sc指令是⼀种在多处理器系统中实现共享内存的原⼦操作的⽅法,且不需要为了让⼀个处理器独占它⽽锁定它。
意思是,你⽤ll指令读取⼀个内存中的数据并存到⼀个寄存器,然后在寄存器修改(或不)这个值,随后⽤sc指令将它写⼊到同样的(原来的)位置。⽽sc指令只在你修改寄存器中的值的期间,没有任何⼀个处理器改变它内存中的值 这种情况下,将值写⼊。它同时需要(的副作⽤是)设置⼀个指⽰状态的变量来表明是否成功写⼊。(成功为1,失败为0)
龙嘴大铜壶当新的值成功地被写⼊了,那么可以认为这个线程在没有别的线程⼲涉的情况下完成了(⼀个值的)读-改-写过程。如果失败了,接下来就取决于程序是要放弃这个操作还是再试⼀次了,不过⾄少它(ll&sc)不会⽣成⼀个隐性的(不被察觉的)竞争危害。

本文发布于:2023-06-11 02:25:33,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1033014.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:指令   线程   内存
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图