1 字节共享资源上的互斥

发布于 2024-09-08 21:55:06 字数 88 浏览 2 评论 0原文

1 字节共享资源是否需要互斥锁?如果不是那么为什么不呢?考虑我使用的是普通台式电脑 pentium IV,32 位。如果使用 core 2 duo,情况会改变吗?

Is Mutex required on 1 byte shared resource? If not then why not? Consider I am using normal desktop PC pentium IV , 32 bit. Will condition change if use core 2 duo?

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

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

发布评论

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

评论(2

书信已泛黄 2024-09-15 21:55:06

这取决于您要用它做什么,但是如果您有多个用 C 或 C++ 实现的编写器,那么您需要一个互斥体 - 资源的大小不是问题。

It depends what you are going to do with it, but if you have multiple writers, implemented in C or C++, then yes you need a mutex - the size of the resource is not the issue.

ぶ宁プ宁ぶ 2024-09-15 21:55:06

CPU 并不重要,因为任务调度程序可以随时中断线程。大小并不重要。如果它是共享的,那么您需要某种锁定方法。

CPU doesn't matter as the task scheduler is free to interrupt a thread at any time. Size doesn't matter. If it's shared then you need some method of locking.

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