当前位置:网站首页>The difference between critical section (the code that accesses critical resources in each thread) and mutex (mutex between processes, shared memory, virtual address)
The difference between critical section (the code that accesses critical resources in each thread) and mutex (mutex between processes, shared memory, virtual address)
2022-07-27 07:24:00 【Dontla】
Read this article today , I feel that the effect of critical area is similar to that of mutex , It's all about locking a piece of code , Let only one thread access , I don't know the difference ...
C Language multithreading foundation -02- A critical region , The mutex
difference :
1、 Critical areas can only be used for mutually exclusive access between threads of objects in the same process ; Mutexes can be used for mutually exclusive access between object processes or threads .
2、 Critical areas are non kernel objects , Lock only in user mode , Fast ; Mutexes are kernel objects , Lock operation in nuclear mentality , Slow speed .
3、 The critical region and mutex are Windows Available on all platforms ;Linux Only mutexes are available under (Linux Only lock can be used under )
Reference article : The difference between critical areas and mutexes
About mutexes between processes ( The mutex ), I don't understand , You can refer to this article :
Linux Interprocess mutex ( Memory sharing )
It is implemented by sharing memory , Calling pthread_mutex_init() Function time , The second parameter needs to pass in a property object ( State object ) The address of
Locks need to be defined on shared memory , About the creation of shared memory , You can refer to this article :
Linux Shared memory encapsulation
in addition , Visible supplementary knowledge :
LINUX Process variable isolation Virtual address
边栏推荐
猜你喜欢

Internal class -- just read this article~

Federal Reserve SR 11-7: Guidance on model risk management - Wanzi collection

How MySQL executes query statements

Jmeter:接口自动化测试-BeanShell对数据库数据和返回数据比较

在kettle使用循环来处理表中的数据

Quartus: an error is reported when adding a.V file to someone else's project

MySQL: 提高最大连接数

(2022牛客多校三)A-Ancestor(LCA)

TCP/IP协议分析(TCP/IP三次握手&四次挥手+OSI&TCP/IP模型)

sql-labs SQL注入平台-第1关Less-1 GET - Error based - Single quotes - String(基于错误的GET单引号字符型注入)
随机推荐
Codeforces Round #787 (Div. 3)(7/7)
Quartus: an error is reported when adding a.V file to someone else's project
pytorch笔记:TD3
js中的数组方法与循环
Codeforces Round #787 (Div. 3)(7/7)
Calledprocesserror during pre commit install
Golang encapsulates the packages involved in MySQL and the differences between sqlx and Gorm
QT连接sqlite数据库的错误及其修改办法
想sink 到 redis-hash 里面 把 对象的属性和值都写进去 ,大佬们有Demo 吗?
Which C4d cloud rendering platform to cooperate with?
Please ask the big guys a question. The pgsqlcdc task can't monitor changes after running for a period of time. Just restart it. What should I do
Port forwarding summary
Drools(5):Drools高级语法
腾讯云服务器SSH链接自动断开解决方法
js做一个红绿灯
Shell系统学习之Shell条件测试,判断语句和运算符
yhb_sysbench
? Experiment 7 implementation of PHP management system based on MySQL
使用pip命令切换不同的镜像源
在kettle使用循环来处理表中的数据