OS学习笔记:Lecture 7

本文详细介绍了操作系统中中断和异常处理的基本概念和技术实现,包括硬件中断、软件中断、异常处理流程、中断优先级分配等内容,并探讨了不同类型的中断屏蔽机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

IPC

Twomodels:

Shared memory: 不会过多干预

Message passing: 有message这个抽象,有mailbox,需要通过receive和send两个接口操作

Send 通过os的buffer

Receiver blocking non-blocking

 

 

Exception

CPU在执行每段指令时都可能调入interrupt handler

Exception table: 包含exception和interrupt

Exception number: 32-127, 129-255 hardware; 128(0x80) systemcall

IDT(interrupt descriptor table) 日常可见的都存储虚拟地址,除了cr3

Exception handler

The processorpushes a return address on the stack (%eip)

not allow to let an application know itself is interrupted

Users are not trustful

Exception handlers run in kernel mode

Kernel stack: trap frame

Source of events cause user->kernel

  1. Device interrupt (pysical pins in CPU)
    1. Nonmaskable interrupt (NMI) input pin
    2. Interrupt (INTR) input pin
  2. Software interrupt: exception
  3. Program faults

 

Xv6: initialize the exception table

 

Interrupt

We must program the device to generate an interrupt, providean interrupt number for it.

 

Early boards

PIC

8259A chip controls every device's interrupt

PIC can be cascaded (connected by pins)

Master: 0-7

Slave: 8-15

APIC, IO-APIC, LAPIC

8259A cannot meet the need of multi-kernel

Advanced PIC

Local APIC, IO-APIC

Interrupt routing

Priority

Assigning IRQs to devices

Hardware-dependent

Some IRQs are fixed by the architecture

IRQ0: timer

IRQ2: cascade pin for 8259A

 

Interrupt priority

Software interrupt

high

NMI

 

INTR

 

TRAP flag

Low

 

EOI: end of interrupt: CPU->PIC

If IRQ come from master: only send to master

If IRQ come from slave: send to slave and master

 

Nested interrupt

a second interrupt occurs when an interrupt routine isexcuting

Maximizing parallelism

Re-entry: 导致代码复杂性高 任何callback机制都可能会产生

同时处理同样问题导致上锁

Interrupts can be interrupted

By different interrupts

Exceptions can be interrupted

Exceptions can nest two levels deep

 

Triple fault

Things never to do in an OS

Panic

 

Interrupt masking

Two different types

Global

Selective

 

Three crucial data-structures

Global descriptor table (GDT)

Interrupt descriptor table (IDT)

Task-state segment (TSS)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值