仅读取共享内存时互斥锁 [英] Mutex locking when shared memory is only read

查看:300
本文介绍了仅读取共享内存时互斥锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的印象是正确的,如果任何线程仅读取而不写入线程之间的共享内存,则不需要互斥保护吗?

Is my impression correct that if shared memory between threads is only read and never written, by any of the threads, mutex protection is unneccessary?

这是因为无论线程被抢占在何处,在重新调度线程后它总是可以再次起飞,并且内存内容不会更改.

It's because wherever a thread is preempted, it can always take off again when rescheduled, and the memory contents would not have changed.

推荐答案

是的,是的,读取同一变量的多个线程不会引起竞争.

Yes, you're right, multiple threads reading the same variable do not introduce a race.

这篇关于仅读取共享内存时互斥锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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