当前位置:网站首页>Why can't semaphores be used in interrupts and why can't interrupt context sleep
Why can't semaphores be used in interrupts and why can't interrupt context sleep
2022-06-22 08:12:00 【Potato, watermelon and sesame】
Whether in books or online , An explanation of this , It's always messy , It's hard to sort out . Most developers probably just know it , Without knowing why . Find a brief explanation on the Internet , An article that is easy to understand , So share it .
1、 interrupt Why not use semaphores in ?
answer : Semaphore It can lead to sleep .
2、 Why can't I sleep when I interrupt ?
( The following is a reprint of : http://blog.chinaunix.net/uid-7332782-id-3213376.html)
After the interrupt occurs ,CPU Jump to the interrupt handling code set by the kernel , This part of the kernel code handles interrupts . The context in this process is the interrupt context .
Why can't functions that may cause sleep be used in the context of interrupts ? First, sleep means putting a process in “ sleep ” state , In this state The process of cannot be scheduled for execution . then , At a certain time , This process may be reset to “ function ” state , Thus, it may be scheduled to execute . so ,“ sleep ” And “ function ” It is for the process , Representing the process task_struct Structure records the status of the process . Kernel “ Scheduler ” adopt task_struct Schedule processes .
however , Interrupt context is not a process , It doesn't exist task_struct, So it It's not schedulable . therefore , You can't sleep in interrupt context .
that , Why does the interrupt context have no corresponding task_struct Structure ?
Interrupts occur very frequently ( At least every millisecond ( See configuration , Probably 10 Milliseconds or other values ) A clock interrupt is generated ), And interrupt processing will be very fast . If a corresponding... Is maintained for the interrupt context task_struct structure , Then this structure is frequently allocated 、 Recycling 、 And affect the management of the scheduler , This will affect the throughput of the whole system .
But in some embedded systems that pursue real-time linux in , Interrupts may also be assigned task_struct structure . This is to avoid a large number of interrupts and continuous nesting , Lead to a period of time CPU Always run in interrupt context , So that some very high priority processes can not be run . This approach can improve the real-time performance of the system , But the cost is a reduction in throughput .
边栏推荐
- MySQL 8.0 under Linux forgets the password
- [Oracle database] mammy tutorial day13 date function
- mapTalks:基础操作与WMS/WMTS地图服务加载
- A glimpse of easy rule
- Summary of basic knowledge of Oracle database SQL statement III: data operation language (DQL)
- 先锋期货安全么?期货开户都是哪些流程?期货手续费怎么降低?
- Model electricity experiment -- Experiment 1 transistor common emitter single transistor amplifier
- Example of using listagg in Oracle 11g (splicing the values of a field into a line, separated by commas)
- SVN 提交子文件夹问题
- How to design the dead shot, the best and eye-catching performance of the watch Vanguard
猜你喜欢

RAID technology

Microsoft Remote Desktop 10.7.6 official

Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function

Use of keepalived high availability cluster

Some suggestions on Oracle SQL query return optimization

LR 2022 ultra detailed installation tutorial "latest"

Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language

It operation and maintenance knowledge map

Example of QT combox
![[songhongkang MySQL database] [advanced chapter] [07] MySQL storage engine](/img/47/62ad1e661e015438c40574f533d8f1.png)
[songhongkang MySQL database] [advanced chapter] [07] MySQL storage engine
随机推荐
Chmod Chmod command
Example of using listagg in Oracle 11g (splicing the values of a field into a line, separated by commas)
LVS Technology Practice
Mystery of power bank
面试突击59:一个表中可以有多个自增列吗?
方阵循环右移
Concatenate the specified character at the end of a number in a string
QT control adds double click event
Template code overview
[Oracle database] wet nurse tutorial day15 DDL, DML, index, view, sequence and deadlock are enough
Model electricity experiment -- Experiment 2 JFET common source amplifier circuit
(7)双向链表
The jdbcurl is configured correctly in the project, but the jdbcurl is the wrong path after the project is started
. Net core technology stack website Collection
Easyui数据表实现增删改
QT error prompt 1:invalid use of incomplete type '***‘
Orientdb batch execute SQL
Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function
模电实验——实验一 晶体管共射极单管放大器
XMIND 2022 mind map active resources?