Peterson-2 互斥算法

发布于 2024-12-18 04:36:08 字数 211 浏览 1 评论 0原文

经典 Peterson-2 算法 的无争用复杂度为 4(因为它执行 4 次读取) /对共享寄存器内存的写操作)是否有某种版本的 Peterson-2 算法,它需要较少的对共享寄存器内存的访问? 显然1次访问是不可能的。但是2次或3次访问呢? 谢谢

The contention-free complexity for classic Peterson-2 algorithm is 4 (because it performs 4 read/write operations to shared-registers memory)Is there some verion of Peterson-2 algorithm, which requires less accesses to shared-registers memory ?
It is obvious that 1 access is impossible.But what about 2 or 3 accesses?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

每个临界区至少需要三个操作:进入时写入和读取(以声明获取互斥锁并验证其他进程尚未获取)、退出时写入(以释放互斥锁)。在进入时,Peterson 算法中的进程id 写入单写入器寄存器interested[id] 和多写入器寄存器turn。以将有界寄存器转变为还保存无界版本号的寄存器为代价,对于两个进程,通过两个单写入器寄存器模拟多写入器寄存器,每次写入 1 次写入,每次读取 1 次读取,从而允许两者的合并写入了彼得森的算法。

At least three operations per critical section are needed: a write and a read on entry (to declare acquisition of the mutex and verify that the other process has not acquired), a write on exit (to release the mutex). On entry, process id in Peterson's algorithm writes the single-writer register interested[id] and the multi-writer register turn. At the cost of turning a bounded register into one that also holds an unbounded version number, for two processes, there's a simulation of a multi-writer register by two single-writer registers that makes 1 write per write and 1 read per read, allowing the merger of the two writes in Peterson's algorithm.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文