当前位置:网站首页>[mit 6.s081] LEC 9: interrupts notes
[mit 6.s081] LEC 9: interrupts notes
2022-07-27 18:28:00 【PeakCrosser】
Lec 9: Interrupts
- Ref: https://github.com/huihongxiao/MIT6.S081/tree/master/lec09-interrupts
- Preparation: xv6 book Chapter 5
summary
Interrupt scenario : Hardware needs the attention of the operating system , If the network card receives a packet , The user presses the button
Interrupts and system calls , trap The mechanism is similar .
- The difference between interrupt and system call
- asynchronous (asynchronous): When hardware generation is interrupted , Interrupt handler Interrupt handler and CPU It has nothing to do with the process currently running on ; The system call still calls the context of the process after entering the kernel Context Run in
- Concurrent (concurrency): CPU And the device that generates the interrupt run in parallel , Equipment and CPU There is real parallelism between
- Device programming (program device): Focus on external equipment
Interrupt related hardware
All devices are connected to the processor , Processor passes PLIC(Platform Level Interrupt Control) Handling interrupts .
PLIC Will route the terminal to a CPU The core of , If all CPU The core is dealing with interrupts , PLIC The interrupt will be kept until it is available CPU. PLIC You need to save some internal data to track the interrupted state .
- Interrupt processing flow :
- Indicates that there is currently an interrupt , Waiting for one CPU The core claims to own it , such PLIC You won't send interrupts to other cores
- CPU Handling interrupts , After processing, we will notify PLIC
- PLIC The message of this interrupt will be cleared
Device drivers
drive : Code for managing devices , Drivers are in the kernel .
The drive is generally divided into two parts ( Not an address space ): The bottom part (bottom part) And the top part (top part).
- The bottom part : Usually interrupt handlers . CPU When you receive an interrupt, you will call the interrupt handler here . Interrupt handlers do not run in the context of a particular process , Just deal with interrupts
- Top section : User process , Or the interface called by the rest of the kernel . about UART, yes read/write Interface .
Usually , There will be some queues in the driver ( buffer ). The code at the top and the interrupt handler at the bottom can read and write to the queue . The queue decouples the top and bottom parts of the drive , Operating equipment and CPU Run other code in parallel on .
Interrupt register
- SIE(Supervisor Interrupt Enable) register : Among them is 1 The bit (E) Special handling of peripheral interrupts , 1 A bit (S) Handling software interrupts , 1 A bit (T) Processing timer interrupt .
- SSTATUS(Supervisor Status) register . Yes 1 Bit control interrupt switch . Every CPU There are opposites SIE and SSTATUS register .
- SIP(Supervisor Interrupt Pending) register : In the event of an interruption , The processor knows the type of current interrupt according to this register
- SCAUSE register : The reason for the interruption
- STVEC register : Save the interrupt program address
Interrupt the process
- Premise : CPU Core set SIE External interrupt bit of register (E)
- Hardware clear SIE Bits of register , Prevent any other interrupts from interrupting CPU
- SEPC Register records the current program counter
- Save the current mode ( user / kernel )
- Set to kernel mode (supervisor mode)
- Set the value of the program counter to STVEC Register value

Interruption and concurrency
- Aspects of interrupt concurrency :
- Equipment and CPU It runs in parallel . The behavior here is not the producer / Consumers in parallel
- Interrupt will stop the currently running program .
- Top of drive (top) And the bottom (bottom) Part of it runs in parallel . Can run in parallel in different CPU, Parallel through lock management .

- producer / Consumers in parallel
- The circular queue
- Team space : Read pointer == The write pointer
- The team is full : The write pointer +1 == Read pointer . When the team is full, the producer will sleep .

Interrupted development
In the past : Interrupts are handled quickly , The hardware can be designed simply
Now? : Interrupt processing slows , It takes a lot of steps , The equipment needs more work , To lessen CPU Deal with the burden 
For fast devices ( High performance equipment , Under normal circumstances CPU Processing requires a lot of interrupts , exceed CPU Its own processing ability ) The processing method is polling (polling): CPU Keep polling (spin) Device until there is data , But it will waste CPU cycle (cycles).
For slow devices , There's no need to poll , But when there is no data CPU Switch to other devices .
边栏推荐
- [MIT 6.S081] Lab8: locks
- 查看端口PID及结束进程
- Collection! 0 basic open source data visualization platform flyfish large screen development guide
- Zhanrui fresh seedlings: enable full scene applications, and massive data needs the integration of AI and IOT
- Marvell公布旗下Arm服务器芯片路线图,下一代性能将比ThunderX2高两倍
- 图形界面编程
- 软件安装相关
- 嘉楠耘智已完成预路演,预计11月20日登陆纳斯达克
- Please ask the great God a question, flinkcdc, the datetime field in synchronous MySQL will become a timestamp. Has anyone ever encountered it
- Salesforce runs all test classes and gets coverage reports
猜你喜欢

MySQL学习 Day1 DDL、DML、DQL基础查询

深度学习:GAT

超实用!阿里P9私藏的Kubernetes学习笔记,看完直呼NB

Dynamic linked list 4 one-way circular linked list (loopsingle Implementation)

Deep learning: gat

发布自己的npm组件库

Deep learning: a survey of behavior recognition

技术分享| 快对讲综合调度系统

Deep recognition: thesis reading_ 2s-agcn cvpr2019 (two stream adaptive graph convolution network based on skeleton action recognition)

Three consecutive high-frequency interview questions of redis online celebrity: cache penetration? Cache breakdown? Cache avalanche?
随机推荐
Linked list storage structure of dynamic linked list 2 stack (linkedstack Implementation)
Binary tree concept
超实用!阿里P9私藏的Kubernetes学习笔记,看完直呼NB
[MIT 6.S081] Lab 4: traps
[MIT 6.S081] Lec 9: Interrupts 笔记
多表查询
MySQL solves the problem of insert failure caused by duplicate unique indexes
[MIT 6.S081] Lab 3: page tables
2021.8.6笔记 jsoup
C杂讲 链表初讲
[MIT 6.S081] Lab 11: networking
2021.8.1笔记 数据库设计
Collection! 0 basic open source data visualization platform flyfish large screen development guide
Here comes the first 5g SOC of MediaTek! A77+g77+apu3.0, officially released on November 26!
发布自己的npm组件库
展锐鲜苗:赋能全场景应用,海量数据需要AI与IoT融合
The first PCIe 5.0 SSD master of Jiangsu Huacun: TSMC 12NM process, mass production in 2020
Together with Samsung, vivo will promote exynos980 dual-mode 5g mobile phone!
华为Mate30 Pro 5G拆解:自研芯片占比过半,美系芯片依然存在!
邮件安全运营难?Coremail携手云商店打造企业邮箱办公新生态!