Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
1 字节共享资源是否需要互斥锁?如果没有,那为什么不呢?考虑我使用的是普通台式电脑 pentium IV,32 位。如果使用 core 2 duo,情况会改变吗?
这取决于你打算用它做什么,但如果你有多个编写器,用 C 或 C++ 实现,那么是的,你需要一个互斥锁——资源的大小不是问题。
CPU 无关紧要,因为任务调度程序可以随时中断线程。大小无关紧要。如果它是共享的,那么您需要某种锁定方法。