当前位置:网站首页>PV operation primitive
PV operation primitive
2022-06-28 01:39:00 【AdamShyly】
" Atomic manipulation (atomic operation) You don't need to synchronized", This is a cliche of multithreaded programming . Atomic operation means that it will not be Thread scheduling The mechanism interrupts the operation ; Once this operation begins , It runs until the end , There won't be any context switch [1] ( Switch to another thread ).
Atomic operations are mostly implemented in assembly language , because c Language can't do this .
Atomicity cannot be guaranteed by software alone -- Must be supported by hardware , So it's architecture related . stay x86 On the platform ,CPU Provides the ability to Means of bus locking .CPU There's a lead on the chip #HLOCK pin, If you prefix an instruction in an assembly language program "LOCK", The assembled machine code makes CPU In executing this command, put #HLOCK pin The potential of the current is lowered , Continue until the end of this command release , To lock the bus , So other things on the same bus CPU You can't access the memory through the bus for the time being , This ensures the atomicity of this instruction in a multiprocessor environment .
—— From baidu baike
And the reason why the operating system passes PV Operation to access semaphores can be used to achieve process mutually exclusive synchronization , It is also because PV Primitives are non interruptible , It's atomic manipulation . According to the introduction to atomic operation in Baidu Encyclopedia above , In single processor mode , When multiple processes access critical resources concurrently ,P Operation primitives can put the process that first executes to the primitive code in a non interruptible state , At this time, other concurrent processes cannot pass CPU Interrupt the process and preempt CPU resources , To enter block state , Wait until the process executes v After operation primitive , Wake up one of the blocked processes and resume ready state .
边栏推荐
- LMSOC:一种对社会敏感的预训练方法
- 药物发现综述-02-分子性质预测
- Maimai hot post: Why are big factories keen on making wheels?
- Some problems in awk
- Informatics Olympiad all in one 1359: enclosed area
- Overview and deployment of GFS distributed file system
- The flutter slivereappbar is fully parsed. All the effects you want are here!
- Official announcement! Apache Doris graduated from the Apache incubator and officially became the top project of Apache!
- 有监督、无监督与半监督学习
- What is a through-hole conductive slip ring?
猜你喜欢

什么是数字化?什么是数字化转型?为什么企业选择数字化转型?

美团动态线程池实践思路已开源

Deepmind | pre training of molecular property prediction through noise removal

Solon 1.8.3 release, cloud native microservice development framework

How to understand query, key and value in transformer

What is digitalization? What is digital transformation? Why do enterprises choose digital transformation?

数据库查询优化:主从读写分离及常见问题

Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data

Electron window background transparent borderless (can be used to start the page)

数据库的新选择 Amazon Aurora
随机推荐
Import the data table in MySQL into Excel
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
【嵌入式基础】内存(Cache,RAM,ROM,Flash)
Web3 technology initial experience and related learning materials
Huawei partners and Developers Conference 2022 | Kirin software cooperates with Huawei to jointly build the computing industry and create a digital intelligence future
Solon 1.8.3 发布,云原生微服务开发框架
Official announcement! Apache Doris graduated from the Apache incubator and officially became the top project of Apache!
评价——灰色关联分析
How to read a paper
Comprehensive evaluation of free, easy-to-use and powerful open source note taking software
Implementation of timed tasks in laravel framework
如何阅读一篇论文
同花顺上能炒股开户吗?安全吗?
Ten MySQL locks, one article will give you full analysis
章凡:飞猪基于因果推断技术的广告投后归因
Review of drug discovery-02-prediction of molecular properties
【牛客讨论区】第四章:Redis
Proe/creo product structure design - continuous research
Redis configuration and optimization of NoSQL
模块化开发