Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异

Size: px
Start display at page:

Download "Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异"

Transcription

1 Linux 操作系统分析 Chapter 5 中断和异常 陈香兰 (xlanchen@ustceducn) 苏州研究院中国科学技术大学 Fall 2014 October 21, 2014 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 1 / 69

2 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 2 / 69

3 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号 4 Linux 内核中软件级中断处理及其数据结构 5 Linux 的软中断 tasklet 以及下半部分 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 3 / 69

4 为什么会有中断? 内核的一个主要功能就是处理硬件外设 I/O 处理器速度一般比外设快很多轮询方式效率不高 内核应当处理其它任务, 只有当外设真正完成 / 准备好了时才转过来处理外设 IO 中断机制就是满足上述条件的一种解决办法 ( 回忆 IO 方式 : 轮询 中断 DMA 等 ) 查看系统中断信息 cat /proc/interrupts /proc/interrupts: to display every IRQ vector in use by the system 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 4 / 69

5 中断和异常 中断 ( 广义 ) 会改变处理器执行指令的顺序, 通常与 CPU 芯片内部或外部硬件电路产生的电信号相对应 中断 异步的 :( 狭义 ) 由硬件随机产生, 在程序执行的任何时候可能出现异常 同步的 : 在 ( 特殊的或出错的 ) 指令执行时由 CPU 控制单元产生 我们用 中断信号 来通称这两种类型的中断 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 5 / 69

6 中断信号的作用 中断信号提供了一种特殊的方式, 使得 CPU 转去运行正常程序之外的代码 比如一个外设采集到一些数据, 发出一个中断信号,CPU 必须立刻响应这个信号, 否则数据可能丢失 当一个中断信号到达时,CPU 必须停止它当前正在做的事, 并切换到一个新的活动以响应这个中断信号 为了做到这这一点, 在进程的内核态堆栈中保存程序计数器的当前值 ( 即 eip 和 cs 寄存器 ) 以便处理完中断的时候能正确返回到中断点, 并把与中断信号相关的一个地址放入进程序计数器, 从而进入中断的处理 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 6 / 69

7 中断信号的处理原则 1 快! 当内核正在做一些别的事情的时候, 中断会随时到来 无辜的正在运行的代码被打断中断处理程序在 run 的时候可能禁止了同级中断中断处理程序对硬件操作, 一般硬件对时间也是非常敏感的内核的目标就是让中断尽可能快的处理完, 尽其所能把更多的处理向后推迟 上半部分 (top half) 和下半部分 (bottom half) 2 允许不同类型中断的嵌套发生, 这样能使更多的 I/O 设备处于忙状态 3 尽管内核在处理一个中断时可以接受一个新的中断, 但在内核代码中还在存在一些临界区, 在临界区中, 中断必须被禁止 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 7 / 69

8 中断上下文与进程上下文 程序的运行必然有上下文, 中断处理程序亦然 中断上下文不同于进程上下文 中断或异常处理程序执行的代码不是一个进程它是一个内核控制路径, 执行内核代码, 在中断发生时正在运行的进程上下文中执行作为一个内核控制路径, 中断处理程序比一个进程要 轻 ( 中断上下文只包含了很有限的几个寄存器, 建立和终止中断上下文所需要的时间很少 ) 假设 : 2 个 interrupt context, 记为 A 和 B 2 个 process, 记为 C 和 D 分析 A,B,C,D 在互相抢占上的关系 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 8 / 69

9 中断上下文与进程上下文 1 假设某个时刻 C 占用 CPU 运行, 此时 A 中断发生, 则 C 被 A 抢占,A 得以在 CPU 上执行 由于 Linux 不为中断处理程序设置 process context,a 只能使用 C 的 kernel stack 作为自己的运行栈 current D 进程 C 进程 B 中断 A 中断 A 中断发生 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 8 / 69

10 中断上下文与进程上下文 2 无论如何,Linux 的 interrupt context A 绝对不会被某个进程 C 或者 D 抢占!! 这是由于所有已经启动的 interrupt contexts, 不管是 interrupt contexts 之间切换, 还是在某个 interrupt context 中执行代码的过程, 决不可能插入 scheduler 调度例程的调用 除非 interrupt context 主动或者被动阻塞进入睡眠, 唤起 scheduler, 但这是必须避免的, 危险性见第 3 点说明 current D 进程 C 进程 B 中断 A 中断 A 中断发生 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 8 / 69

11 中断上下文与进程上下文 3 关于第 2 点的解释 : 首先,interrupt context 没有 process context,a 中断是 借 了 C 的进程上下文运行的, 若允许 A 阻塞 或 睡眠, 则 C 将被迫阻塞或睡眠, 仅当 A 被 唤醒 C 才被唤醒 ; 而 唤醒 后,A 将按照 C 在就绪队列中的顺序被调度 这既损害了 A 的利益也污染了 C 的 kernel stack 其次, 如果 interrupt context A 由于阻塞或是其他原因睡眠, 外界对系统的响应能力将变得不可忍受 current D 进程 C 进程 B 中断 A 中断 A 中断发生 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 8 / 69

12 中断上下文与进程上下文 4 那么 interrupt context A 和 B 的关系又如何呢? 由于可能在 interrupt context 的某个步骤打开了 CPU 的 IF flag 标志, 这使得在 A 过程中,B 的 irq line 已经触发了 PIC, 进而触发了 CPU IRQ pin, 使得 CPU 执行中断 B 的 interrupt context, 这是中断上下文的嵌套过程 5 通常 Linux 不对不同的 interrupt contexts 设置优先级, 这种任意的嵌套是允许的 当然可能某个实时 Linux 的 patch 会不允许低优先级的 interrupt context 抢占高优先级的 interrupt context current D 进程 C 进程 B 中断 A 中断 A 中断发生 开中断 B 中断发生 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 8 / 69

13 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号 4 Linux 内核中软件级中断处理及其数据结构 5 Linux 的软中断 tasklet 以及下半部分 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 9 / 69

14 中断和异常 (Intel 文档 ) 中断分为 : 可屏蔽中断 (Maskable interrupt) I/O 设备发出的所有中断请求 (IRQ) 都可以产生可屏蔽中断 可屏蔽中断可以处于两种状态 : 屏蔽 (masked) 和非屏蔽 (unmasked) 非屏蔽中断 (Nonmaskable interrupt, NMI) 只有几个特定的危急事件才引起非屏蔽中断 如硬件故障或是掉电 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 10 / 69

15 中断和异常 (Intel 文档 ) 异常分为 : 处理器探测异常 由 CPU 执行指令时探测到一个反常条件时产生, 如溢出 除 0 错等 编程异常 由编程者发出的特定请求产生, 通常由 int 类指令触发通常叫做 软中断 例如 Linux 使用 int 0x80 来实现系统调用 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 10 / 69

16 中断和异常 (Intel 文档 ) 对于处理器探测异常, 根据返回地址 ( 即异常时保存在内核堆栈中的 eip 的值 ) 的不同, 可以进一步分为 : 1 故障 (fault):eip= 引起故障的指令的地址 通常可以纠正, 处理完异常时, 该指令被重新执行例如缺页异常 2 陷阱 (trap):eip= 随后要执行的指令的地址 3 异常中止 (abort):eip=??? 发生严重的错误 eip 值无效, 只有强制终止受影响的进程 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 10 / 69

17 中断向量 每个中断和异常由 0~255 之间的一个数 (8 位 ) 来标识, Intel 称其为中断向量 非屏蔽中断的向量和异常的向量是固定的可屏蔽中断的向量可以通过对中断控制器的编程来改变 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 11 / 69

18 中断的产生 每个能够发出中断请求的硬件设备控制器都有一条称为 IRQ(Interrupt ReQuest) 的输出线 所有的 IRQ 线都与一个中断控制器的输入引脚相连中断控制器与 CPU 的 INTR 引脚相连 设备 设备控制器 IRQ 中断控制器 INTR CPU 中断控制器执行下列动作 : 1 监视 IRQ 线, 对引发信号检查 2 如果一个引发信号出现在 IRQ 线上 1 把此信号转换成对应的中断向量 2 把这个向量存放在中断控制器的一个 I/O 端口, 从而允许 CPU 通过数据总线读这个向量 3 把引发信号发送到处理器的 INTR 引脚, 即在 CPU 上产生一个中断 4 等待, 直到 CPU 应答此信号 ; 收到应答后, 清 INTR 引脚 3 返回第一步 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 12 / 69

19 IRQ 号和中断向量号 中断控制器对输入的 IRQ 线从 0 开始顺序编号 IR0,IR1,,IR7 Intel 给中断控制器分配的中断向量号从 32 开始, 上述 IRQ 线对应的中断向量依次是 可以对中断控制器编程 : 修改起始中断向量的值, 或有选择的屏蔽 / 激活每条 IRQ 线 注意 : 1 屏蔽 丢失 : 屏蔽的中断不会丢失一旦被激活, 中断控制器又会将它们发送到 CPU 2 有选择的屏蔽 / 激活 IRQ 线 全局屏蔽 / 激活 前者通过对中断控制器编程实现后者通过特定的指令操作 CPU 中的状态字 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 13 / 69

20 I386: 开中断和关中断 CPU 可以屏蔽所有的可屏蔽中断 Eflags 中的 IF 标志 : 0= 关中断 ; 1= 开中断 关中断时,CPU 不响应中断控制器发布的任何中断请求内核中使用 cli 和 sti 指令分别清除和设置该标志 关中断和开中断, 参见 include/asm-x86/irqflagsh static inline void native_irq_disable(void) { asm volatile( cli : : : memory ); } static inline void native_irq_enable(void) { asm volatile( sti : : : memory ); } 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 14 / 69

21 传统的中断控制器 :8259A 传统的中断控制器使用两片 8259A 以 级联 的方式连接在一起每个芯片可以处理最多 8 个不同的 IRQ 线主从两片 8259A 的连接 : 从片 主片的 IRQ2 引脚 设备 8259 主 8259 从 CPU OS 因此, 一共可以处理最多 15 个不同的 IRQ 线 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 15 / 69

22 传统的中断控制器 :8259A 8259A: 设置起始中断向量号参见 arch/x86/kernel/i8259_32c::init_8259a() void init_8259a(int auto_eoi) { /* * outb_pic - this has to work on a wide range of PC hardware */ outb_pic(0x11, PIC_MASTER_CMD); /* ICW1: select 8259A-1 init */ outb_pic(0x20 + 0, PIC_MASTER_IMR); /* ICW2: 8259A-1 IR0-7 mapped to 0x20-0x27 */ outb_pic(1u << PIC_CASCADE_IR, PIC_MASTER_IMR); /* 8259A-1 (the master) has a slave on IR2 */ if (auto_eoi) /* master does Auto EOI */ outb_pic(master_icw4_default PIC_ICW4_AEOI, PIC_MASTER_IMR); else /* master expects normal EOI */ outb_pic(master_icw4_default, PIC_MASTER_IMR); } outb_pic(0x11, PIC_SLAVE_CMD); /* ICW1: select 8259A-2 init */ outb_pic(0x20 + 8, PIC_SLAVE_IMR); /* ICW2: 8259A-2 IR0-7 mapped to 0x28-0x2f */ outb_pic(pic_cascade_ir, PIC_SLAVE_IMR); /* 8259A-2 is a slave on master s IR2 */ outb_pic(slave_icw4_default, PIC_SLAVE_IMR); /* 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 15 / 69

23 传统的中断控制器 :8259A } 8259A: 禁止 / 激活某个 IRQ 线, 参见 arch/x86/kernel/i8259_32c void disable_8259a_irq(unsigned int irq) { unsigned int mask = 1 << irq; unsigned long flags; spin_lock_irqsave(&i8259a_lock, flags); cached_irq_mask = mask; if (irq & 8) outb(cached_slave_mask, PIC_SLAVE_IMR); else outb(cached_master_mask, PIC_MASTER_IMR); spin_unlock_irqrestore(&i8259a_lock, flags); unsigned int cached_irq_mask = 0xffff; include/asm-x86/i8259h 中 : #define byte(x, y) (((unsigned char *)&(y))[x]) #define cached_master_mask ( byte(0, cached_irq_mask)) #define cached_slave_mask ( byte(1, cached_irq_mask)) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 15 / 69

24 传统的中断控制器 :8259A } 8259A: 禁止 / 激活某个 IRQ 线, 参见 arch/x86/kernel/i8259_32c void enable_8259a_irq(unsigned int irq) { unsigned int mask = ~(1 << irq); unsigned long flags; spin_lock_irqsave(&i8259a_lock, flags); cached_irq_mask &= mask; if (irq & 8) outb(cached_slave_mask, PIC_SLAVE_IMR); else outb(cached_master_mask, PIC_MASTER_IMR); spin_unlock_irqrestore(&i8259a_lock, flags); unsigned int cached_irq_mask = 0xffff; include/asm-x86/i8259h 中 : #define byte(x, y) (((unsigned char *)&(y))[x]) #define cached_master_mask ( byte(0, cached_irq_mask)) #define cached_slave_mask ( byte(1, cached_irq_mask)) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 15 / 69

25 异常 X86 处理器发布了大约 20 种不同的异常 某些异常通过硬件出错码说明跟异常相关的信息内核为每个异常提供了一个专门的异常处理程序 # Exception type Exception handler Signal 0 Divide error fault divide_error() SIGFPE 1 Debug fault/trap debug() SIGTRAP 2 NMI interrupt nmi() None 3 Breakpoint trap int3() SIGTRAP 4 Overflow trap overflow() SIGSEGV 5 Bounds check fault bounds() SIGSEGV 6 Invalid opcode fault invalid_op() SIGILL 7 Device not available fault device_not_available() SIGSEGV 8 Double fault Abort double_fault() SIGSEGV 9 Coprocessor segment overrun fault coprocessor_segment_overrun() SIGFPE 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 16 / 69

26 异常 # Exception type Exception handler Signal 10 Invalid TSS fault invalid_tss() SIGSEGV 11 Segment not present fault segment_not_present() SIGBUS 12 Stack exception fault stack_segment() SIGBUS 13 General protection fault general_protection() SIGSEGV 14 Page Fault fault page_fault() SIGSEGV 15 Intel reserved - None None 16 Floating-pointer error fault coprocessor_error SIGFPE 17 Alignment check fault alignment_check() SIGBUS 18 Machine check Abort machine_check() None 19 SIMD floating point fault simd_coprocessor_error() SIGFPE 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 16 / 69

27 中断描述符表 (Interrupt Descriptor Table,IDT) 中断描述符表是一个系统表, 它与每一个中断或者异常向量相联系 每个向量在表中有相应的中断或者异常处理程序的入口地址 每个描述符 8 个字节, 共 256 项, 占用空间 2KB 内核在允许中断发生前, 必须先对 IDT 表进行适当的初始化 CPU 的 idtr 寄存器指向 IDT 表的物理基地址 lidt 指令 IDT 包含 3 种类型的描述符 : 任务门 中断门和陷阱门 陷阱门与中断门类似, 但进入陷阱门时, 系统不会进入关中断状态 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 17 / 69

28 中断描述符表 (Interrupt Descriptor Table,IDT) Task Gate Descriptor D RESERVED P P RESERVED L TSS SEGMENT SELECTOR RESERVED Interrupt Gate Descriptor D OFFSET(16-31) P P RESERVED L SEGMENT SELECTOR OFFSET(0-15) Trap Gate Descriptor D OFFSET(16-31) P P RESERVED L SEGMENT SELECTOR OFFSET(0-15) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 17 / 69

29 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构 5 Linux 的软中断 tasklet 以及下半部分 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 18 / 69

30 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 19 / 69

31 中断和异常的硬件处理 : 进入中断 / 异常 假定 : 内核已经初始化,CPU 在保护模式下运行 CPU 的正常运行 : 当执行了一条指令后,cs 和 eip 这对寄存器包含了下一条将要执行的指令的逻辑地址 在执行这条指令之前,CPU 控制单元会检查在运行前一条指令时是否发生了一个中断或者异常 如果发生了一个中断或异常, 那么 CPU 控制单元中断当前任务的运行转而进入中断处理 硬件进入中断处理的过程如下 : 1 确定与中断或者异常关联的向量 i(0~255) 2 读 idtr 寄存器指向的 IDT 表中的第 i 项 3 从 gdtr 寄存器获得 GDT 的基地址, 并在 GDT 中查找, 以读取 IDT 表项中的段选择符所标识的段描述符 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 20 / 69

32 中断和异常的硬件处理 : 进入中断 / 异常 4 确定中断是由授权的发生源发出的 中断 : 中断处理程序的特权不能低于引起中断的程序的特权 ( 对应 GDT 表项中的 DPL vs CS 寄存器中的 CPL) ( 注 : 中断例程只能由内核提供, 用户进程运行时可以发生中断 ) 编程异常 : 还需比较 CPL 与对应 IDT 表项中的 DPL 5 检查是否发生了特权级的变化, 一般指是否由用户态陷入了内核态 若是, 控制单元必须开始使用与新的特权级相关的堆栈 a, 即内核态栈 1 读 tr 寄存器, 访问运行进程的 tss 段 2 用与新特权级相关的栈段和栈指针装载 ss 和 esp 寄存器 这些值可以在进程的 tss 段中找到 3 在新的栈中保存 ss 和 esp 以前的值, 这些值指明了与旧特权级相关的栈的逻辑地址 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 20 / 69

33 中断和异常的硬件处理 : 进入中断 / 异常 6 若发生的是故障, 用引起异常的指令地址修改 cs 和 eip 寄存器的值, 以使得这条指令在异常处理结束后能被再次执行 7 在栈中保存 eflags cs 和 eip 的内容 8 如果异常产生一个硬件出错码, 则将它保存在栈中 9 装载 cs 和 eip 寄存器, 其值分别是 IDT 表中第 i 项门描述符的段选择符和偏移量字段 这对寄存器值给出中断或者异常处理程序的第一条指定的逻辑地址 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 20 / 69

34 中断和异常的硬件处理 : 进入中断 / 异常 此时的进程内核态堆栈 ( 注意此进程可以是任意一个进程, 中断处理程序不关心这个 ) 8KB union ss esp eflags cs eip 从用户态进入中断 / 异常 esp 入内核时保存的 ss,esp, eflags,cs 和 eip eflags cs eip 从内核态进入中断 / 异常 esp thread_info thread_info 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 20 / 69

35 中断和异常的硬件处理 : 进入中断 / 异常 此时的进程内核态堆栈 ( 注意此进程可以是任意一个进程, 中断处理程序不关心这个 ) 8KB union ss esp eflags cs eip error code 从用户态进入中断 / 异常 esp 入内核时保存的 ss,esp, eflags,cs 和 eip eflags cs eip error code 从内核态进入中断 / 异常 esp thread_info 若异常有出错码 thread_info 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 20 / 69

36 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 21 / 69

37 中断和异常的硬件处理 : 从中断 / 异常返回 中断 / 异常处理完后, 相应的处理程序会执行一条 iret 汇编指令, 这条汇编指令让 CPU 控制单元做如下事情 : 1 用保存在栈中的值装载 cs eip 和 eflags 寄存器 如果一个硬件出错码曾被压入栈中, 那么弹出这个硬件出错码 2 检查处理程序的特权级是否等于 cs 中最低两位的值 ( 这意味着进程在被中断的时候是运行在内核态还是用户态 ) 若是,iret 终止执行 ; 否则, 转入 3 3 从栈中装载 ss 和 esp 寄存器 这步意味着返回到与旧特权级相关的栈 4 检查 ds es fs 和 gs 段寄存器的内容, 如果其中一个寄存器包含的选择符是一个段描述符, 并且特权级比当前特权级高, 则清除相应的寄存器 这么做是防止怀有恶意的用户程序利用这些寄存器访问内核空间 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 22 / 69

38 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 23 / 69

39 中断和异常处理程序的嵌套执行 当内核处理一个中断或异常时, 就开始了一个新的内核控制路径 当 CPU 正在执行一个与中断相关的内核控制路径时,linux 不允许进程切换 不过, 一个中断处理程序可以被另外一个中断处理程序中断, 这就是中断的嵌套执行 抢占原则 普通进程可以被中断或异常处理程序打断异常处理程序可以被中断程序打断中断程序只可能被其他的中断程序打断 Linux 允许中断嵌套的原因 提高可编程中断控制器和设备控制器的吞吐量实现了一种没有优先级的中断模型 陈香兰 ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 24 / 69

40 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 25 / 69

41 初始化中断描述符表 内核启动中断前, 必须初始化 IDT, 然后把 IDT 的基地址装载到 idtr 寄存器中 Linux 在启动和初始化的不同阶段, 均有对 IDT 表的初始化和加载 1 进入保护模式前 IDT 表的初始化 2 idt_table 的初步初始化 3 Start_kernel 中 idt_table 的初始化 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 26 / 69

42 1 进入保护模式前 IDT 表的初始化 } arch/x86/boot/pmc::go_to_protected_mode 中调用 setup_idt 来初始化一个临时的 IDT 表 struct gdt_ptr { u16 len; u32 ptr; } attribute ((packed)); static void setup_idt(void) { static const struct gdt_ptr null_idt = {0, 0}; asm volatile( lidtl %0 : : m (null_idt)); 此时,IDT 表的起始地址填充为 0, 其长度填充为 0 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 27 / 69

43 2 idt_table 的初步初始化 idt_table 的定义, 参见 arch/x86/kernel/traps_32c gate_desc idt_table[256] attribute (( section ( dataidt ))) = { { { { 0, 0 } } }, }; 其中, 门描述符 gate_desc 在 include/asm-x86/desc_defsh 中定义 : struct desc_struct { union { struct { unsigned int a; unsigned int b; }; struct { u16 limit0; u16 base0; unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1; unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8; }; }; } attribute ((packed)); typedef struct desc_struct gate_desc; 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 28 / 69

44 2 idt_table 的初步初始化 idt_table 的初步初始化为 : 1 用 ignore_int() 函数填充 256 个 idt_table 表项, 参见 arch/x86/kernel/head_32s::setup_idt 2 使用 early_divide_err early_illegal_opcode early_protection_fault 和 early_page_fault 初始化对应的异常向量 setup_idt /* * setup_idt * * sets up a idt with 256 entries pointing to * ignore_int, interrupt gates It doesn t actually load * idt - that can be done only after paging has been enabled * and the kernel moved to PAGE_OFFSET Interrupts * are enabled elsewhere, when we can be relatively * sure everything is ok * * Warning: %esi is live across this function */ 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 28 / 69

45 2 idt_table 的初步初始化 setup_idt: lea ignore_int,%edx movl $( KERNEL_CS << 16),%eax movw %dx,%ax /* selector = 0x0010 = cs */ movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ lea idt_table,%edi mov $256,%ecx rp_sidt: movl %eax,(%edi) movl %edx,4(%edi) addl $8,%edi dec %ecx jne rp_sidt 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 28 / 69

46 2 idt_table 的初步初始化 ignore_int /* This is the default interrupt handler :-) */ ALIGN ignore_int: cld #ifdef CONFIG_PRINTK pushl %eax pushl %ecx pushl %edx pushl %es pushl %ds movl $( KERNEL_DS),%eax movl %eax,%ds movl %eax,%es cmpl $2,early_recursion_flag je hlt_loop incl early_recursion_flag pushl 16(%esp) int_msg: asciz Unknown interrupt or fault at EIP %p %p %p\n 陈香兰 ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 28 / 69 pushl 24(%esp) pushl 32(%esp) pushl 40(%esp) pushl $int_msg #ifdef CONFIG_EARLY_PRINTK call early_printk #else call printk #endif addl $(5*4),%esp popl %ds popl %es popl %edx popl %ecx popl %eax #endif iret

47 2 idt_table 的初步初始化 early_page_fault: movl $14,%edx jmp early_fault early_fault: cld #ifdef CONFIG_PRINTK pusha movl $( KERNEL_DS),%eax movl %eax,%ds movl %eax,%es cmpl $2,early_recursion_flag je hlt_loop incl early_recursion_flag movl %cr2,%eax pushl %eax pushl %edx /* trapno */ pushl $fault_msg #ifdef CONFIG_EARLY_PRINTK call early_printk #else call printk 以 early_page_fault 为例 #endif #endif call dump_stack hlt_loop: hlt jmp hlt_loop 该例程输出异常发生时的关键硬件上下文 fault_msg: /* fault info: */ ascii BUG: Int %d: CR2 %p\n /* pusha regs: */ ascii EDI %p ESI %p EBP %p ESP %p\n ascii EBX %p EDX %p ECX %p EAX %p\n /* fault frame: */ ascii err %p EIP %p CS %p flg %p\n ascii Stack: %p %p %p %p %p %p %p %p\n ascii %p %p %p %p %p %p %p %p\n asciz %p %p %p %p %p %p %p %p\n 陈香兰 ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 28 / 69

48 3 Start_kernel 中 idt_table 的初始化 int 指令允许用户进程发出一个中断信号, 其值可以是 的任意一个向量 例如 int3 为了防止用户用 int 指令非法模拟中断和异常,IDT 的初始化时要很小心的设置特权级 然而用户进程有时必须要能发出一个编程异常, 例如 int 0x80 为了做到这一点, 只要把相应的中断或陷阱门描述符的特权级设置成 3 由此,Linux 在 x86 的中断门 / 陷阱门的基础上实现了 Linux 的中断门 陷阱门和系统门 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

49 3 Start_kernel 中 idt_table 的初始化 1 Linux 的中断门 用户态的进程不能访问的一个 Intel 中断门 ( 特权级为 0), 所有的中断都通过中断门激活, 并全部在内核态 2 Linux 的系统门 1 用户态的进程可以访问的一个 Intel 陷阱门 ( 特权级为 3), 通过系统门来激活 4 个 linux 异常处理程序, 它们的向量是 3,4,5 和 128 因此, 在用户态下可以发布 int3,into, bound 和 int $0x80 四条汇编指令 3 Linux 的陷阱门 1 用户态的进程不能访问的一个 Intel 陷阱门 ( 特权级为 0), 大部分 linux 异常处理程序通过陷阱门激活 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

50 3 Start_kernel 中 idt_table 的初始化 } 下列体系结构相关的函数用来在 IDT 中设置门, 参见 include/asm-x86/desch static inline void set_intr_gate(unsigned int n, void *addr) { \ BUG_ON((unsigned)n > 0xFF); _set_gate(n, GATE_INTERRUPT, addr, 0, 0, KERNEL_CS); } static inline void set_system_intr_gate(unsigned int n, void *addr) { BUG_ON((unsigned)n > 0xFF); _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, KERNEL_CS); } static inline void set_trap_gate(unsigned int n, void *addr) { BUG_ON((unsigned)n > 0xFF); _set_gate(n, GATE_TRAP, addr, 0, 0, KERNEL_CS); } static inline void set_system_gate(unsigned int n, void *addr) {, _set_gate(n, GATE_TRAP, addr, 0x3, 0, KERNEL_CS); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

51 3 Start_kernel 中 idt_table 的初始化 } 下列体系结构相关的函数用来在 IDT 中设置门, 参见 include/asm-x86/desch static inline void pack_gate(gate_desc *gate, unsigned char type, unsigned long base, unsigned dpl, unsigned flags, unsigned short seg) { gate->a = (seg << 16) (base & 0xffff); gate->b = (base & 0xffff0000) (((0x80 type (dpl << 5)) & 0xff) << 8); } static inline void _set_gate(int gate, unsigned type, void *addr, unsigned dpl, unsigned ist, unsigned seg) { gate_desc s; pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg); write_idt_entry(idt_table, gate, &s); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

52 3 Start_kernel 中 idt_table 的初始化 } Start_kernel 中的 IDT 表初始化 :trap_init,init_irq void init trap_init(void) { set_trap_gate(0, &divide_error); set_intr_gate(1, &debug); set_intr_gate(2, &nmi); set_system_intr_gate(3, &int3); /* int3/4 can be called from all */ set_system_gate(4, &overflow); set_trap_gate(5, &bounds); set_trap_gate(6, &invalid_op); set_trap_gate(7, &device_not_available); set_task_gate(8, GDT_ENTRY_DOUBLEFAULT_TSS); set_trap_gate(9, &coprocessor_segment_overrun); set_trap_gate(10, &invalid_tss); set_trap_gate(11, &segment_not_present); set_trap_gate(12, &stack_segment); set_trap_gate(13, &general_protection); set_intr_gate(14, &page_fault); set_trap_gate(19, &simd_coprocessor_error); set_system_gate(syscall_vector, &system_call); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

53 3 Start_kernel 中 idt_table 的初始化 Start_kernel 中的 IDT 表初始化 :trap_init,init_irq init_irq() 即 native_init_irq() void init native_init_irq(void) { /* all the set up before the call gates are initialised */ pre_intr_init_hook(); for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) { int vector = FIRST_EXTERNAL_VECTOR + i; if (i >= NR_IRQS) break; /* SYSCALL_VECTOR was reserved in trap_init */ if (!test_bit(vector, used_vectors)) set_intr_gate(vector, interrupt[i]); } /* setup after call gates are initialised (usually add in * the architecture specific gates) */ intr_init_hook(); } 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 29 / 69

54 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 30 / 69

55 异常处理 CPU 产生的大部分异常都由 linux 解释为出错条件 当一个异常发生时, 内核就向引起异常的进程发送一个信号通知它发生了一个反常条件 异常处理有一个标准的结构, 由三部分组成 1 在内核态堆栈中保存大多数寄存器的内容 2 调用 C 语言的函数 3 通过 ret_from_exception() 从异常处理程序退出 观察 entry_32s, 并找到 C 语言函数的定义之处 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

56 异常处理 以 14 号缺页异常的处理为例 : 在 arch/x86/kernel/traps_32c::trap_init 中, 14 号异常的处理入口函数被设置为 page_fault ṣet_intr_gate(14, &page_fault); page_fault 的原型在 arch/x86/kernel/traps_32c 中被申明为 : ạsmlinkage void page_fault(void); page_fault 实际上是在 arch/x86/kernel/entry_32s 中以汇编码的形式定义的 KPROBE_ENTRY(page_fault) pushl $do_page_fault error_code: 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

57 异常处理 以 14 号缺页异常的处理为例 : 在 arch/x86/kernel/traps_32c::trap_init 中, 14 号异常的处理入口函数被设置为 page_fault ṣet_intr_gate(14, &page_fault); page_fault 的原型在 arch/x86/kernel/traps_32c 中被申明为 : ạsmlinkage void page_fault(void); 此时的内 ss page_fault 实际上是在 arch/x86/kernel/entry_32s 核态堆栈 : esp 中以汇编码的形式定义的 eflags cs eip KPROBE_ENTRY(page_fault) error code do_page_fault pushl $do_page_fault esp error_code: thread_info 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

58 异常处理 阅读 error_code, 参见 arch/x86/kernel/entry_32s error_code: /* the function address is in %fs s slot on the stack */ pushl %es pushl %ds pushl %eax pushl %ebp pushl %edi pushl %esi pushl %edx pushl %ecx pushl %ebx cld pushl %fs movl $( KERNEL_PERCPU), %ecx movl %ecx, %fs popl %ecx movl PT_FS(%esp), %edi # get the function address movl PT_ORIG_EAX(%esp), %edx # get the error code movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart mov %ecx, PT_FS(%esp) movl $( USER_DS), %ecx movl %ecx, %ds movl %ecx, %es movl %esp,%eax # pt_regs pointer call *%edi jmp ret_from_exception 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

59 异常处理 阅读 error_code, 参见 arch/x86/kernel/entry_32s 运行 call 指令前 error_code: /* the function address is in %fs s slot on the stack */ pushl %es pushl %ds pushl %eax pushl %ebp pushl %edi pushl %esi pushl %edx pushl %ecx pushl %ebx cld pushl %fs movl $( KERNEL_PERCPU), %ecx movl %ecx, %fs popl %ecx movl PT_FS(%esp), %edi # get the function address movl PT_ORIG_EAX(%esp), %edx # get the error code movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart mov %ecx, PT_FS(%esp) movl $( USER_DS), %ecx movl %ecx, %ds movl %ecx, %es movl %esp,%eax # pt_regs pointer call *%edi jmp ret_from_exception 内核态堆栈 : edi 为 : do_page_fault edx 为 : error_code eax 为 : pt_regs 指针 ss esp eflags cs eip -1 fs es ds eax ebp edi esi edx ecx ebx thread_info esp 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

60 异常处理 阅读 error_code, 参见 arch/x86/kernel/entry_32s 运行 call 指令前 error_code: /* the function address is in %fs s slot on the stack */ pushl %es pushl %ds pushl %eax pushl %ebp pushl %edi pushl %esi pushl %edx pushl %ecx pushl %ebx cld pushl %fs movl $( KERNEL_PERCPU), %ecx movl %ecx, %fs popl %ecx movl PT_FS(%esp), %edi # get the function address movl PT_ORIG_EAX(%esp), %edx # get the error code movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart mov %ecx, PT_FS(%esp) movl $( USER_DS), %ecx movl %ecx, %ds movl %ecx, %es movl %esp,%eax # pt_regs pointer call *%edi jmp ret_from_exception do_page_fault 为寄存器传参, 它的第一个参数取自 eax, 第二个参数取自 edx 内核态堆栈 : edi 为 : do_page_fault edx 为 : error_code eax 为 : pt_regs 指针 ss esp eflags cs eip -1 fs es ds eax ebp edi esi edx ecx ebx thread_info esp 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

61 异常处理 } do_page_fault 在 arch/x86/mm/faultc 中定义 void kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code) { 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

62 异常处理 pt_regs 结构 ( 恢复现场所需的上下文 ), 参见 include/asm-x86/ptraceh struct pt_regs { unsigned long bx; unsigned long cx; unsigned long dx; unsigned long si; unsigned long di; unsigned long bp; unsigned long ax; unsigned long ds; unsigned long es; unsigned long fs; /* int gs; */ unsigned long orig_ax; unsigned long ip; unsigned long cs; unsigned long flags; unsigned long sp; unsigned long ss; }; 运行 call 指令前内核态堆栈 : edi 为 : do_page_fault edx 为 : error_code eax 为 : pt_regs 指针 ss esp eflags cs eip -1 fs es ds eax ebp edi esi edx ecx ebx thread_info esp 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

63 异常处理 当 C 函数终止时, 根据内核栈中的返回地址, CPU 从 call *%edi 这条指令的下一条指令开始继续执行, 即 : jmp ret_from_exception 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 31 / 69

64 低级异常处理小结 低级中断处理过程可以归纳为 : 1 保存上下文 2 调用异常相关的 C 语言函数, 如 do_page_fault 3 恢复上下文, 从异常返回 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 32 / 69

65 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 33 / 69

66 中断的类型 中断跟异常不同, 它并不是表示程序出错, 而是硬件设备有所动作, 所以不是简单地往当前进程发送一个信号就 OK 的 主要有三种类型的中断 : I/O 设备发出中断请求时钟中断处理器间中断 ( 在 SMP, Symmetric Multiprocessor 上才有 ) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 34 / 69

67 I/O 中断处理 I/O 中断处理程序必须足够灵活以给多个设备同时提供服务 比如几个设备可以共享同一个 IRQ 线 (2 个 8259 级联也只能提供 15 根 IRQ 线, 所以外设共享 IRQ 线是很正常的 ) 这就意味着仅仅中断向量解决不了全部问题 灵活性以两种不同的方式达到 1 IRQ 共享 : 中断处理程序执行多个中断服务例程 (interrupt service routines, ISRs) 每个 ISR 是一个与单独设备 ( 共享 IRQ 线 ) 相关的函数 2 IRQ 动态分配 : 一条 IRQ 线在可能的最后时刻才与一个设备相关联 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 35 / 69

68 中断向量分配表 Vector range Use 0-19 (0x0-0x13) Nonmaskable interrupts and exceptions (0x14-0x1f) Intel reserved (0x20-0x7f) External interrupts (IRQs) 128 (0x80) Programmed exception for system calls (0x81-0xee) External interrupts (IRQs) 239 (0xef) Local APIC timer interrupt (0xf0-0xfa) Reserved by Linux for future use (0xfb-0xff) Interprocessor interrupts 陈香兰 ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 36 / 69

69 设备中断 IRQ INT Hardware Device 0 32 Timer 1 33 Keyboard 2 34 PIC cascading 3 35 Second serial port 4 36 Frist serial port 6 38 Floppy disk 8 40 System clock Network interface USB port, sound card PS/2 mouse Mathematical coprocessor EIDE disk controller s first chain EIDE disk controller s second chain 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 37 / 69

70 Linux 的中断处理原则 为了保证系统对外部的响应, 一个中断处理程序必须被尽快的完成 因此, 把所有的操作都放在中断处理程序中并不合适 Linux 中把紧随中断要执行的操作分为三类 1 紧急的 (critical) 一般关中断运行 诸如对 PIC 应答中断, 对 PIC 或是硬件控制器重新编程, 或者修改由设备和处理器同时访问的数据 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 38 / 69

71 Linux 的中断处理原则 2 非紧急的 (noncritical) 如修改那些只有处理器才会访问的数据结构 ( 例如按下一个键后读扫描码 ), 这些也要很快完成, 因此由中断处理程序立即执行, 不过一般在开中断的情况下 3 非紧急可延迟的 (noncritical deferrable) 如把缓冲区内容拷贝到某个进程的地址空间 ( 例如把键盘缓冲区内容发送到终端处理程序进程 ) 这些操作可以被延迟较长的时间间隔而不影响内核操作, 有兴趣的进程将会等待数据 内核用下半部分这样一个机制来在一个更为合适的时机用独立的函数来执行这些操作 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 38 / 69

72 Linux 的中断处理原则 不管引起中断的设备是什么, 所有的 I/O 中断处理程序都执行四个相同的基本操作 1 在内核态堆栈保存 IRQ 的值和寄存器的内容 2 为正在给 IRQ 线服务的 PIC 发送一个应答, 这将允许 PIC 进一步发出中断 3 执行共享这个 IRQ 的所有设备的中断服务例程 4 跳到 ret_from_intr() 的地址 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 38 / 69

73 低级中断处理 } 系统初始化时, 调用 arch/x86/kernel/i8259_32c::init_irq() 用新的中断门替换临时中断门来更新 IDT /* Overridden in paravirtc */ void init_irq(void) attribute ((weak, alias( native_init_irq ))); void init native_init_irq(void) { for (i = 0; i < (NR_VECTORS - FIRST_EXTERNAL_VECTOR); i++) { int vector = FIRST_EXTERNAL_VECTOR + i; if (i >= NR_IRQS) break; /* SYSCALL_VECTOR was reserved in trap_init */ if (!test_bit(vector, used_vectors)) set_intr_gate(vector, interrupt[i]); } 这段代码在 interrupt 数组中找到用于建立中断门的中断处理程序地址 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

74 低级中断处理 Interrupt 数组, 在 include/asm-x86/hw_irq_32h 被声明为 extern void ( const interrupt[nr_irqs]) (void); 但其定义比较隐晦, 参见 arch/x86/kernel/entry_32s section rodata, a ENTRY(interrupt) text ENTRY(irq_entries_start) vector=0 rept NR_IRQS 1: pushl $~(vector) jmp common_interrupt previous long 1b text vector=vector+1 endr END(irq_entries_start) previous END(interrupt) previous 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

75 低级中断处理 Interrupt 数组, 在 include/asm-x86/hw_irq_32h 被声明为 extern void ( const interrupt[nr_irqs]) (void); ss 但其定义比较隐晦, 参见 arch/x86/kernel/entry_32s section rodata, a ENTRY(interrupt) text ENTRY(irq_entries_start) vector=0 rept NR_IRQS 1: pushl $~(vector) jmp common_interrupt previous long 1b text vector=vector+1 endr END(irq_entries_start) previous END(interrupt) previous 内核态堆栈 : esp eflags cs eip thread_info 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69 esp

76 低级中断处理 Interrupt 数组, 在 include/asm-x86/hw_irq_32h 被声明为 extern void ( const interrupt[nr_irqs]) (void); ss 但其定义比较隐晦, 参见 arch/x86/kernel/entry_32s section rodata, a ENTRY(interrupt) text ENTRY(irq_entries_start) vector=0 rept NR_IRQS 1: pushl $~(vector) jmp common_interrupt previous long 1b text vector=vector+1 endr END(irq_entries_start) previous END(interrupt) previous 内核态堆栈 : esp eflags cs eip ~vector thread_info 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69 esp

77 低级中断处理 arch/x86/kernel/entry_32s::common_interrupt 为 /* * the CPU automatically disables interrupts when executing an IRQ vector, * so IRQ-flags tracing has to follow that: */ ALIGN common_interrupt: SAVE_ALL TRACE_IRQS_OFF movl %esp,%eax call do_irq jmp ret_from_intr ENDPROC(common_interrupt) CFI_ENDPROC 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

78 低级中断处理 其中,arch/x86/kernel/entry_32S::SAVE_ALL, 精简后如下 : #define SAVE_ALL \ cld; \ pushl %fs; \ pushl %es; \ pushl %ds; \ pushl %eax; \ pushl %ebp; \ pushl %edi; \ pushl %esi; \ pushl %edx; \ pushl %ecx; \ pushl %ebx; \ movl $( USER_DS), %edx; \ movl %edx, %ds; \ movl %edx, %es; \ movl $( KERNEL_PERCPU), %edx; \ movl %edx, %fs 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

79 低级中断处理 其中,arch/x86/kernel/entry_32S::SAVE_ALL, 精简后如下 eflags : #define SAVE_ALL \ cld; \ pushl %fs; \ pushl %es; \ pushl %ds; \ pushl %eax; \ pushl %ebp; \ pushl %edi; \ pushl %esi; \ pushl %edx; \ pushl %ecx; \ pushl %ebx; \ movl $( USER_DS), %edx; \ movl %edx, %ds; \ movl %edx, %es; \ movl $( KERNEL_PERCPU), %edx; \ movl %edx, %fs 运行 call 指令前内核态堆栈 : eax 为 : pt_regs 指针 ss esp cs eip ~vector fs es ds eax ebp edi esi edx ecx ebx thread_info esp 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

80 低级中断处理 do_irq 在 arch/x86/kernel/irq_32c 中定义, 它使用寄存器 eax 传参 (eax 在 common_interrupt 中指向栈顶的 pt_regs 结构 ) unsigned int do_irq(struct pt_regs regs) {} 小结, 每个中断程序入口操作 ( 即低级中断处理 ) 为 : 1 将中断向量信息入栈 2 保存所有其他寄存器 3 调用 do_irq 4 跳转到 ret_from_intr 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 39 / 69

81 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 40 / 69

82 中断描述符表 irq_desc[] do_irq 在 arch/x86/kernel/irq_32c 中提供, 它使用与体系结构无关的中断描述符表 irq_desc[]: unsigned int do_irq(struct pt_regs *regs) { struct pt_regs *old_regs; /* high bit used in ret_from_ code */ int irq = ~regs->orig_ax; struct irq_desc *desc = irq_desc + irq; 1 从寄存器上下文中获得 irq 号 2 从 Linux 中断描述符中找到 irq 号对应的中断描述符 desc Linux 中断描述符表 :irq_desc 数组包含了 NR_IRQS( 通常为 224=256-32) 个 irq_desc_t 描述符 在 include/linux/irqh 中声明 : extern struct irq_desc irq_desc[nr_irqs]; 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 41 / 69

83 中断描述符表 irq_desc[] 中断描述符数据结构 irq_desc 在 include/linux/irqh 中定义 /** * struct irq_desc - interrupt descriptor * highlevel irq-events handler [if NULL, do_irq()] low level interrupt hardware access MSI descriptor per-irq data for the irq_chip methods platform-specific per-chip private data for the chip * methods, to allow shared chip implementations the irq action chain status information disable-depth, for nested irq_disable() calls enable depth, for multiple set_irq_wake() callers stats field to detect stalled irqs stats field for spurious unhandled interrupts aging timer for unhandled count locking for SMP IRQ affinity on SMP cpu index useful for balancing pending rebalanced interrupts /proc/irq/ procfs entry /proc/irq/smp_affinity procfs entry on SMP flow handler name for /proc/interrupts output */ 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 41 / 69

84 中断描述符表 irq_desc[] 中断描述符数据结构 irq_desc 在 include/linux/irqh 中定义 struct irq_desc { irq_flow_handler_t handle_irq; struct irq_chip *chip; struct msi_desc *msi_desc; void *handler_data; void *chip_data; struct irqaction *action; /* IRQ action list */ unsigned int status; /* IRQ status */ unsigned int depth; /* nested irq disables */ unsigned int wake_depth; /* nested wake enables */ unsigned int irq_count; /* For detecting broken IRQs */ unsigned int irqs_unhandled; unsigned long last_unhandled; /* Aging timer for unhandled count */ spinlock_t lock; const char *name; } cacheline_internodealigned_in_smp; 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 41 / 69

85 中断描述符表 irq_desc[] 中断描述符表 irq_desc[] 的定义和最初的初始化, 参见 kernel/irq/handlec struct irq_desc irq_desc[nr_irqs] cacheline_aligned_in_smp = { [0 NR_IRQS-1] = { status = IRQ_DISABLED, chip = &no_irq_chip, handle_irq = handle_bad_irq, depth = 1, lock = SPIN_LOCK_UNLOCKED(irq_desc->lock), #ifdef CONFIG_SMP affinity = CPU_MASK_ALL #endif } }; Linux 中断描述符表 irq_desc[] 的几个关键数据结构和类型 1 irqaction 数据结构 2 irq_chip 3 irq_flow_handler_t 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 41 / 69

86 irq_action 数据结构 irqaction 数据结构, 参见 include/linux/interrupth 用来实现 IRQ 的共享, 维护共享 irq 的特定设备和特定中断, 所有共享一个 irq 的链接在一个 action 表中, 由中断描述符中的 action 指针指向 struct irqaction { irq_handler_t handler; unsigned long flags; cpumask_t mask; const char *name; void *dev_id; struct irqaction *next; int irq; struct proc_dir_entry *dir; }; 设置 irqaction 的函数 :kernel/irq/managec::setup_irq 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 42 / 69

87 irq_action 数据结构 } 以时钟中断为例, 在时钟中断初始化时注册时钟的 irqaction ( 参见 arch/x86/mach-default/setupc) static struct irqaction irq0 = { handler = timer_interrupt, flags = IRQF_DISABLED IRQF_NOBALANCING IRQF_IRQPOLL, mask = CPU_MASK_NONE, name = timer }; /** * time_init_hook - do any specific initialisations for the system timer * * Description: * Must plug the system timer interrupt source at HZ into the IRQ listed * in irq_vectorsh:timer_irq **/ void init time_init_hook(void) { irq0mask = cpumask_of_cpu(0); setup_irq(0, &irq0); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 42 / 69

88 irq_chip 数据结构 为特定 PIC 编写的低级 I/O 例程, 参见 include/linux/irqh /** * struct irq_chip - hardware interrupt chip descriptor * name for /proc/interrupts start up the interrupt (defaults to ->enable if NULL) shut down the interrupt (defaults to ->disable if NULL) enable the interrupt (defaults to chip->unmask if NULL) disable the interrupt (defaults to chip->mask if NULL) start of a new interrupt mask an interrupt source ack and mask an interrupt source unmask an interrupt source end of interrupt - chip level end of interrupt - flow level set the CPU affinity on SMP machines resend an IRQ to the CPU set the flow type (IRQ_TYPE_LEVEL/etc) of an IRQ enable/disable power-management wake-on of an IRQ * release function solely used by UML obsoleted by name, kept as migration helper */ 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 43 / 69

89 irq_chip 数据结构 }; 为特定 PIC 编写的低级 I/O 例程, 参见 include/linux/irqh struct irq_chip { const char *name; unsigned int (*startup)(unsigned int irq); void (*shutdown)(unsigned int irq); void (*enable)(unsigned int irq); void (*disable)(unsigned int irq); void (*ack)(unsigned int irq); void (*mask)(unsigned int irq); void (*mask_ack)(unsigned int irq); void (*unmask)(unsigned int irq); void (*eoi)(unsigned int irq); void (*end)(unsigned int irq); void (*set_affinity)(unsigned int irq, cpumask_t dest); int (*retrigger)(unsigned int irq); int (*set_type)(unsigned int irq, unsigned int flow_type); int (*set_wake)(unsigned int irq, unsigned int on); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 43 / 69

90 irq_chip 数据结构 例如 8259 的 irq_chip, 参见 arch/x86/kernel/i8259_32c static struct irq_chip i8259a_chip = { name = XT-PIC, mask = disable_8259a_irq, disable = disable_8259a_irq, unmask = enable_8259a_irq, mask_ack = mask_and_ack_8259a, }; 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 43 / 69

91 irq_chip 数据结构 } 为一个中断设置 irq_chip 的函数有 set_irq_chip_and_handler_name set_irq_chip 等 例如 : 在 init_irq( 即 native_init_irq) 中, 调用的 pre_intr_init_hook 可能如下定义 (arch/x86/machdefault/setupc) void init pre_intr_init_hook(void) { init_isa_irqs(); 其中,init_ISA_irqs 在 arch/x86/kernel/i8259_32c 中定义 void init init_isa_irqs (void) { for (i = 0; i < 16; i++) { set_irq_chip_and_handler_name(i, &i8259a_chip, handle_level_irq, XT ); } } 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 43 / 69

92 irq_chip 数据结构 } 又如 :arch/x86/kernel/i8259_32c::make_8259a_irq void make_8259a_irq(unsigned int irq) { disable_irq_nosync(irq); io_apic_irqs &= ~(1<<irq); set_irq_chip_and_handler_name(irq, &i8259a_chip, handle_level_irq, XT ); enable_irq(irq); 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 43 / 69

93 关于 irq_flow_handler_t 缺省为 handle_bad_irq set_irq_handler 设置 handle_irq 数据项 handle_level_irq 8259 handle_simple_irq handle_fasteoi_irq handle_edge_irq handle_percpu_irq 以 kernel/irq/chipc::handle_level_irq 为例 : 它调用 kernel/irq/handlec::handle_irq_event, 进一步调用 atction->handler, 从而使得设备相关的中断处理函数得以运行 关于 action->handler( 设备相关的中断处理函数 ): 在 kernel/irq/managec::setup_irq 时, 由 irqaction 参数给定 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 44 / 69

94 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 45 / 69

95 do_irq 的调用和返回 在调用 do_irq 之前, 要保存上下文返回之后, 要恢复上下文 在 interrupt[] 数组中定义的中断处理程序中 每个入口地址转换成汇编码是如下的一些指令 interrupt[irq]: pushl $~(vector) jmp common_interrupt 这里对所有的中断处理程序都执行相同的代码 common_interrupt: SAVE_ALL movl %esp,%eax call do_irq jmp $ret_from_intr 陈香兰 ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 46 / 69

96 arch/x86/kernel/irq_32c::do_irq() do_irq() 函数的等价代码 : int irq = ~regs->orig_ax; //1 irq_desc[irq]->handle_irq(irq, desc); //2 mask_ack_irq(desc, irq); //3 handle_irq_event(irq,&regs,irq_desc[irq]action); //4 irq_desc[irq]handler->end(irq); //5 处理下半部分 //6 1 句取得对应的中断向量 2 句调用中断处理句柄, 对 8259, 就是 handle_level_irq 3 句应答 PIC 的中断, 并禁用这条 IRQ 线 ( 为串行处理同类型中断 ) 4 调用 handle_irq_event() 执行中断服务例程, 例如 timer_interrupt 5 句通知 PIC 重新激活这条 IRQ 线, 允许处理同类型中断 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 47 / 69

97 kernel/irq/handlec::handle_irq_evnet() 和中断服务例程 一个中断服务例程实现一种特定设备的操作, handle_irq_evnet() 函数依次调用这些设备例程 这个函数本质上执行了如下核心代码 : do{ action->handler(irq,action->dev_id,regs); action = action->next; }while (action) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 48 / 69

98 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号 4 Linux 内核中软件级中断处理及其数据结构 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 49 / 69

99 软中断 tasklet 以及下半部分 对内核来讲, 可延迟中断不是很紧急, 可以将它们从中断处理例程中抽取出来, 保证较短的中断响应时间 Linux26 提供了三种方法来执行可延迟操作 ( 函数 ): 1 软中断 软中断由内核静态分配 ( 编译时确定 ) 2 tasklet Tasklet 在软中断之上实现一般原则 : 在同一个 CPU 上软中断 /tasklet 不嵌套 Tasklet 可以在运行时分配和初始化 ( 例如装入一个内核模块时 ) 3 工作队列 ( work queues ) 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 50 / 69

100 软中断 tasklet 以及下半部分 一般而言, 可延迟函数上可以执行 4 种操作 1 初始化 : 定义一个新的可延迟函数, 通常在内核初始化时进行 2 激活 : 设置可延迟函数在下一轮处理中执行 3 屏蔽 : 有选择的屏蔽一个可延迟函数, 这样即使被激活也不会被运行 4 执行 : 在特定的时间执行可延迟函数 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 50 / 69

101 Outline 1 中断信号的作用和处理的一般原则 2 I/O 设备如何引起 CPU 中断 3 x86 CPU 如何在硬件级处理中断信号中断和异常的硬件处理 : 进入中断 / 异常中断和异常的硬件处理 : 从中断 / 异常返回 4 Linux 内核中软件级中断处理及其数据结构初始化中断描述符表低级异常处理低级中断处理 Linux 体系无关部分的中断管理数据结构 do_irq 的中断处理过程 5 Linux 的软中断 tasklet 以及下半部分 Linux 的软中断 softirq Tasklet 工作队列和工作线程 6 作业 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 51 / 69

102 软中断 softirq 管理的关键数据结构 Linux2626 使用有限个软中断, 具体参见 include/linux/interrupth enum { HI_SOFTIRQ=0, TIMER_SOFTIRQ, NET_TX_SOFTIRQ, NET_RX_SOFTIRQ, BLOCK_SOFTIRQ, TASKLET_SOFTIRQ, SCHED_SOFTIRQ, #ifdef CONFIG_HIGH_RES_TIMERS HRTIMER_SOFTIRQ, #endif RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */ }; 软中断的编号越小, 优先级越高 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 52 / 69

103 软中断 softirq 管理的关键数据结构 软中断的向量表 softirq_vec 定义, 参见 kernel/softirqc ṣtatic struct softirq_action softirq_vec[32] cacheline_aligned_in_smp; 每一个软中断向量由数据结构 softirq_action 定义, 参见 include/linux/interrupth struct softirq_action { void (*action)(struct softirq_action *); void *data; }; 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 计算机学院嵌入式系统实验室 Chapter 5 苏州研究院中国科学技术大学 October 21, Fall ) 52 / 69

1 CPU interrupt INT trap CPU exception

1 CPU interrupt INT trap CPU exception 1 CPU interrupt INT trap CPU exception 2 X86 CPU gate 64 16 1 2 5 8 16 16 P DPL 00101 TSS 101 DPL P 1 64 16 1 2 1 1 3 3 5 16 16 16 P DPL 0 D 000 16 110 111 100 D 1=32 0=16 DPL P 1 INT DPL1>=CPL>=DPL CPU

More information

06721 main() lock pick proc() restart() [2][4] MINIX minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU _hwint00:! Interrupt

06721 main() lock pick proc() restart() [2][4] MINIX minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU _hwint00:! Interrupt MINIX ( 730000) ( 730000) MINIX MINIX2.0 MINIX : MINIX TP3 1 MINIX UNIX Tanenbaum UNIX MINIX LINUX MINIX MINIX MINIX1.0 UNIX V7 MINIX2.0[3] POSIX MINIX3 MINIX Gabriel A. Wainer 1994-1995 [5] 1998 I/O 2002

More information

提纲. 1 实验准备. 2 从实模式进入保护模式. 3 小结 陈香兰 ( 中国科学技术大学计算机学院 ) 软件综合实验之操作系统 July 1, / 11

提纲. 1 实验准备. 2 从实模式进入保护模式. 3 小结 陈香兰 ( 中国科学技术大学计算机学院 ) 软件综合实验之操作系统 July 1, / 11 .. 软件综合实验之操作系统 进入保护模式 陈香兰 中国科学技术大学计算机学院 July 1, 2016 陈香兰 ( 中国科学技术大学计算机学院 ) 软件综合实验之操作系统 July 1, 2016 1 / 11 提纲. 1 实验准备. 2 从实模式进入保护模式. 3 小结 陈香兰 ( 中国科学技术大学计算机学院 ) 软件综合实验之操作系统 July 1, 2016 2 / 11 实验准备 实验环境准备

More information

Linux kernel exploit研究和探索

Linux kernel exploit研究和探索 Linux kernel exploit DOC alert7 PPT e4gle 2002-12-2 1 2002-12-2 2 Linux kernel exploit kernel exploit exploit exploit exploit (Kernel Buffer Overflow) (Kernel

More information

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

A Preliminary Implementation of Linux Kernel Virus and Process Hiding 邵 俊 儒 翁 健 吉 妍 年 月 日 学 号 学 号 学 号 摘 要 结 合 课 堂 知 识 我 们 设 计 了 一 个 内 核 病 毒 该 病 毒 同 时 具 有 木 马 的 自 动 性 的 隐 蔽 性 和 蠕 虫 的 感 染 能 力 该 病 毒 获 得 权 限 后 会 自 动 将 自 身 加 入 内 核 模 块 中 劫 持 的 系 统 调 用 并 通 过 简 单 的 方 法 实 现 自 身 的

More information

Bus Hound 5

Bus Hound 5 Bus Hound 5.0 ( 1.0) 21IC 2007 7 BusHound perisoft PC hound Bus Hound 6.0 5.0 5.0 Bus Hound, IDE SCSI USB 1394 DVD Windows9X,WindowsMe,NT4.0,2000,2003,XP XP IRP Html ZIP SCSI sense USB Bus Hound 1 Bus

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

untitled

untitled 8086/8088 CIP /. 2004.8 ISBN 7-03-014239-X.... TP313 CIP 2004 086019 16 100717 http://www.sciencep.com * 2004 8 2004 8 1 5 500 787 1092 1/16 16 1/2 391 000 1 2 ii 1 2 CAI CAI 3 To the teacher To the student

More information

Microsoft PowerPoint - os_4.ppt

Microsoft PowerPoint - os_4.ppt 行 程 資 科 系 林 偉 川 行 程 概 念 行 程 與 程 式 主 要 的 不 同 點 : 程 式 是 被 放 在 外 部 的 儲 存 裝 置 如 磁 碟 上, 而 行 程 則 被 放 在 記 憶 體 中 程 式 在 儲 存 裝 置 中 是 靜 態 的, 而 行 程 在 記 憶 體 中 是 動 態 的, 它 會 隨 著 一 些 事 件 的 發 生 而 產 生 相 對 的 改 變 行 程, 就 是

More information

<4D F736F F D20B5DAC8FDCBC4D5C2D7F7D2B5B4F0B0B82E646F63>

<4D F736F F D20B5DAC8FDCBC4D5C2D7F7D2B5B4F0B0B82E646F63> 第三章 Q3 1 1. 省略了 I/O 操作的复杂逻辑, 易实现, 耗费低 ; 2. 可以利用丰富的内存寻址模式实现灵活的 I/O 操作 Q3 2 假设存储单元 ds1 处寄存器地址为 0x2000, 代码如下 #define ds1 0x2000 while ( *ds1 == 0 ) ; Q3 3 假设设备 (dev1) 中有两个寄存器 ds1 和 dd1,dev1 的地址为 0x1000,ds1

More information

Kernel Kernel Kernel Kernel load estimator runqueue kernel/sched.

Kernel Kernel Kernel Kernel load estimator runqueue kernel/sched. Linux Kernel 2.6 20321131 Kernel 2.4...3 Kernel 2.4...3 Kernel 2.4...3 Kernel 2.6...3...3 1....3 2....4 3. load estimator...4 4....4 5....4...4 1....4 2. runqueue kernel/sched.c...4 3. task_struct(include/linux/sched.h)...6...9

More information

P4VM800_BIOS_CN.p65

P4VM800_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Fri 02/25/2005] BIOS Version : P4VM800 BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

36 asm ("mov %%fs,%%ax":"=a" ( res):); \ 37 res;}) 38 // 以下定义了一些函数原型 39 void page_exception(void); // 页异常 实际是 page_fault(mm/page.s,14) void divi

36 asm (mov %%fs,%%ax:=a ( res):); \ 37 res;}) 38 // 以下定义了一些函数原型 39 void page_exception(void); // 页异常 实际是 page_fault(mm/page.s,14) void divi 程序 8-2 linux/kernel/traps.c 1 /* 2 * linux/kernel/traps.c 3 * 4 * (C) 1991 Linus Torvalds 5 */ 6 7 /* 8 * 'Traps.c' handles hardware traps and faults after we have saved some 9 * state in 'asm.s'. Currently

More information

Microsoft Word - 11.doc

Microsoft Word - 11.doc 除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

Microsoft PowerPoint - C15_LECTURE_NOTE_11

Microsoft PowerPoint - C15_LECTURE_NOTE_11 INTERRUPT INTERFACE OF THE 8088 AND 8086 MICROPROCESSOR INTERRUPT INTERFACE OF THE 8088 AND 8086 MICROPROCESSOR 11.1 Interrupt Mechanism, Types and Priority 11.2 Interrupt Vector Table 11.3 Interrupt Instructions

More information

Andes Technology PPT Temp

Andes Technology PPT Temp 晶心科技線上技術研討會 AndesCore 便捷的全 C 嵌入式编程 晶心科技市場及技術服務部毛礼杰軟件經理 WWW.ANDESTECH.COM 大纲 系统初始化介绍 异常和中断说明 全 C 语法例子说明 总结 2 CPU 相关特性 1: 中断向量表 系统初始化 (1) 2: 系统寄存器 通常需要用 assembly( 汇编 / 组合 ) 语言来操作 AndesCore 全 C 嵌入式编程 C 扩展语法

More information

Linux 操作系统分析 Chapter 9-2 Linux 中程序的执行 陈香兰 苏州研究院中国科学技术大学 Fall 2014 November 4,

Linux 操作系统分析 Chapter 9-2 Linux 中程序的执行 陈香兰  苏州研究院中国科学技术大学 Fall 2014 November 4, Linux 操作系统分析 Chapter 9-2 Linux 中程序的执行 陈香兰 (xlanchen@ustceducn) 计算机应用教研室 @ 计算机学院嵌入式系统实验室 @ 苏州研究院中国科学技术大学 Fall 2014 November 4, 2014 陈香兰 (xlanchen@ustceducn) ( 计算机应用教研室 Linux 操作系统分析 @ 计算机学院嵌入式系统实验室 Chapter

More information

P4V88+_BIOS_CN.p65

P4V88+_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Wed 12/22/2004] BIOS Version : P4V88+ BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

untitled

untitled 2006 6 Geoframe Geoframe 4.0.3 Geoframe 1.2 1 Project Manager Project Management Create a new project Create a new project ( ) OK storage setting OK (Create charisma project extension) NO OK 2 Edit project

More information

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2

User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2 Terminal Mode No User User ID 150 Password - User ID 150 Password Mon- Cam-- Invalid Terminal Mode No User Terminal Mode No User Mon- Cam-- 2 Mon1 Cam-- Mon- Cam-- Prohibited M04 Mon1 Cam03 Mon1 Cam03

More information

浙江大学本科论文模板

浙江大学本科论文模板 本 科 生 毕 业 设 计 报 告 项 目 名 称 微 型 操 作 系 统 的 设 计 与 实 现 姓 名 与 学 号 曲 国 铖 3063027053 指 导 老 师 王 新 宇 专 业 计 算 机 科 学 与 技 术 学 院 计 算 机 学 院 A Dissertation Submitted to Zhejiang University for the Degree of Bachelor of

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

穨control.PDF

穨control.PDF TCP congestion control yhmiu Outline Congestion control algorithms Purpose of RFC2581 Purpose of RFC2582 TCP SS-DR 1998 TCP Extensions RFC1072 1988 SACK RFC2018 1996 FACK 1996 Rate-Halving 1997 OldTahoe

More information

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP Serial ATA ( Sil3132)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 10 (5) S A T A... 12 Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

BC04 Module_antenna__ doc

BC04 Module_antenna__ doc http://www.infobluetooth.com TEL:+86-23-68798999 Fax: +86-23-68889515 Page 1 of 10 http://www.infobluetooth.com TEL:+86-23-68798999 Fax: +86-23-68889515 Page 2 of 10 http://www.infobluetooth.com TEL:+86-23-68798999

More information

<4D6963726F736F667420576F7264202D20C7B6C8EBCABDCFB5CDB3C9E8BCC6CAA6B0B8C0FDB5BCD1A75FD1F9D5C22E646F63>

<4D6963726F736F667420576F7264202D20C7B6C8EBCABDCFB5CDB3C9E8BCC6CAA6B0B8C0FDB5BCD1A75FD1F9D5C22E646F63> 因 为 路 过 你 的 路, 因 为 苦 过 你 的 苦, 所 以 快 乐 着 你 的 快 乐, 追 逐 着 你 的 追 逐 内 容 简 介 本 书 根 据 2005 年 下 半 年 实 施 的 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 嵌 入 式 系 统 设 计 师 级 考 试 大 纲 精 神, 在 深 入 研 究 历 年 计 算 机 技 术 与 软

More information

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO Car DVD New GUI IR Flow User Manual V0.1 Jan 25, 2008 19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 Web: www.sunplus.com Important Notice SUNPLUS

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

Microsoft Word - MSP430 Launchpad 指导书.docx

Microsoft Word - MSP430 Launchpad 指导书.docx Contents 3... 9... 14 MSP430 LAUNCHPAD 指导书 3 第一部分第一个工程 New Project File > New > CCS Project Project name: ButtonLED Device>Family: MSP430 Variant: MSP430G2553 Project templates and examples : Empty Project

More information

目录

目录 ALTERA_CPLD... 3 11SY_03091... 3 12SY_03091...4....5 21 5 22...8 23..10 24..12 25..13..17 3 1EPM7128SLC.......17 3 2EPM7032SLC.......18 33HT46R47......19..20 41..20 42. 43..26..27 5151DEMO I/O...27 52A/D89C51...28

More information

ARM JTAG实时仿真器安装使用指南

ARM JTAG实时仿真器安装使用指南 ARM JTAG Version 1.31 2003. 11. 12 ARM JTAG ARM JTAG.3 ARM 2.1.4 2.2.4 ARM JTAG 3.1 18 3.2 18 3.2.1 Multi-ICE Server.18 3.2.2 ADS..21 ARM JTAG 4.1 Multi-ICE Server 33 4.1.1 Multi-ICE Server..... 33 4.1.2

More information

ebook140-8

ebook140-8 8 Microsoft VPN Windows NT 4 V P N Windows 98 Client 7 Vintage Air V P N 7 Wi n d o w s NT V P N 7 VPN ( ) 7 Novell NetWare VPN 8.1 PPTP NT4 VPN Q 154091 M i c r o s o f t Windows NT RAS [ ] Windows NT4

More information

1 CPU

1 CPU 2000 Tel 82316285 82317634 Mail liuxd@buaa.edu.cn 1 CPU 2 CPU 7 72 A B 85 15 3 1/2 M301 2~17 : 3/4 1/2 323 IBM PC 1. 2. 3. 1. 2. 3. 1.1 Hardware Software 1.2 M3 M2 M1 1.2 M3 M1 M2 M2 M1 M1 M1 1.2 M3 M1

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information

ROP_bamboofox.key

ROP_bamboofox.key ROP Return Oriented Programming Lays @ BambooFox Who Am I Lays / L4ys / 累死 - l4ys.tw Reverse Engineering BambooFox / HITCON Outline Buffer Overflow ret2libc / ret2text Return Oriented Programming Payload

More information

RAID RAID 0 RAID 1 RAID 5 RAID * ( -1)* ( /2)* No Yes Yes Yes A. B. BIOS SATA C. RAID BIOS RAID ( ) D. SATA RAID/AHCI ( ) SATA M.2 SSD ( )

RAID RAID 0 RAID 1 RAID 5 RAID * ( -1)* ( /2)* No Yes Yes Yes A. B. BIOS SATA C. RAID BIOS RAID ( ) D. SATA RAID/AHCI ( ) SATA M.2 SSD ( ) RAID RAID 0 RAID 1 RAID 5 RAID 10 2 2 3 4 * (-1)* (/2)* No Yes Yes Yes A. B. BIOS SATA C. RAID BIOS RAID ( ) D. SATA RAID/AHCI ( ) SATA M.2 SSD ( ) ( ) ( ) Windows USB 1 SATA A. SATASATAIntel SATA (SATA3

More information

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor 1 4.1.1.1 (Load) 14 1.1 1 4.1.1.2 (Save) 14 1.1.1 1 4.1.2 (Buffer) 16 1.1.2 1 4.1.3 (Device) 16 1.1.3 1 4.1.3.1 (Select Device) 16 2 4.1.3.2 (Device Info) 16 2.1 2 4.1.3.3 (Adapter) 17 2.1.1 CD-ROM 2 4.1.4

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un Linux C July 27, 2016 Contents 1 Linux IDE 1 2 GCC 3 2.1 hello.c hello.exe........................... 5 2.2............................... 9 2.2.1 -Wall................................ 9 2.2.2 -E..................................

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20

,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far address L10: jmp jmp L20: L10 L20 (Jump) (Loop) (Conditional jump) CMP CALL AND SAR/SHR TEST JMP NOT SAL/SHL Jnnn* OR RCR/ROR LOOP XOR RCL/ROL RETn * nnn, JNE JL -128 127-32,768 32,767 32K JMP Jnnn (386+) LOOP CALL [Label:] JMP short/near/far

More information

Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Microsoft Win

Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Microsoft Win Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A... 11 (6) Microsoft Windows 2000... 14 Ác Åé å Serial ATA ( Nvidia nforce430)

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

More information

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile.. WebSphere Studio Application Developer IBM Portal Toolkit... 1/21 WebSphere Studio Application Developer IBM Portal Toolkit Portlet Doug Phillips (dougep@us.ibm.com),, IBM Developer Technical Support Center

More information

IP505SM_manual_cn.doc

IP505SM_manual_cn.doc IP505SM 1 Introduction 1...4...4...4...5 LAN...5...5...6...6...7 LED...7...7 2...9...9...9 3...11...11...12...12...12...14...18 LAN...19 DHCP...20...21 4 PC...22...22 Windows...22 TCP/IP -...22 TCP/IP

More information

CONTENTS Chapter - Introduction Chapter 2 - Hardware Installation Chapter 3 - BIOS Setup Utility Chapter 4 - Supported Software M804

CONTENTS Chapter - Introduction Chapter 2 - Hardware Installation Chapter 3 - BIOS Setup Utility Chapter 4 - Supported Software M804 MBS-S65B-ML Pentium 4 478-pin processor Based DDR MAIN BOARD CONTENTS Chapter - Introduction Chapter 2 - Hardware Installation Chapter 3 - BIOS Setup Utility Chapter 4 - Supported Software M804 Chapter

More information

学习MSP430单片机推荐参考书

学习MSP430单片机推荐参考书 MSP430 16 MSP430 C MSP430 C MSP430 FLASH 16 1 CPU 16 ALU 16 PC SP SR R4~R15 2 3 00-FFH 100-1FFH 4 5 1 2 51 24 27 6 1 2 3 4 5 6 4 12 SR SP SR CPU SR CPU C Z N GIE CPUOff CPU OscOff SCG0 SCG1 CPU EXIT SP

More information

员工签到录

员工签到录 Archivist 2002 Eletech Enterprise Co., Ltd. All Rights Reserved. 1-1 ELETECH VOICE SYSTEMS INC 2 / 2 VLR, 1-1-1 VP894AS-M11 1. VP894AS-M11 1 2. Y 4 3. RJII 4 4. 2-PIN 1 5. VLR 1 2 3 4 ELETECH VOICE SYSTEMS

More information

bingdian001.com

bingdian001.com TSM12M TSM12 STM8L152C6, STM8L152R8 MSP430F5325 whym1987@126.com! /******************************************************************************* * : TSM12.c * : * : 2013/10/21 * : TSM12, STM8L f(sysclk)

More information

科学计算的语言-FORTRAN95

科学计算的语言-FORTRAN95 科 学 计 算 的 语 言 -FORTRAN95 目 录 第 一 篇 闲 话 第 1 章 目 的 是 计 算 第 2 章 FORTRAN95 如 何 描 述 计 算 第 3 章 FORTRAN 的 编 译 系 统 第 二 篇 计 算 的 叙 述 第 4 章 FORTRAN95 语 言 的 形 貌 第 5 章 准 备 数 据 第 6 章 构 造 数 据 第 7 章 声 明 数 据 第 8 章 构 造

More information

目 录

目 录 1 Quick51...1 1.1 SmartSOPC Quick51...1 1.2 Quick51...1 1.3 Quick51...2 2 Keil C51 Quick51...4 2.1 Keil C51...4 2.2 Keil C51...4 2.3 1 Keil C51...4 2.4 Flash Magic...9 2.5 ISP...9 2.6...10 2.7 Keil C51...12

More information

ICD ICD ICD ICD ICD

ICD ICD ICD ICD ICD MPLAB ICD2 MPLAB ICD2 PIC MPLAB-IDE V6.0 ICD2 usb PC RS232 MPLAB IDE PC PC 2.0 5.5V LED EEDATA MPLAB ICD2 Microchip MPLAB-IDE v6.0 Windows 95/98 Windows NT Windows 2000 www.elc-mcu.com 1 ICD2...4 1.1 ICD2...4

More information

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING 前言 - Andrew Payne 目录 1 2 Firefly Basics 3 COMPONENT TOOLBOX 目录 4 RESOURCES 致谢

More information

ebook15-10

ebook15-10 1 0 10.1 U N I X V 7 4. 3 B S D S V R 3 P O S I X. 1 100 % 10.2 S I G S I G A B RT a b o r t S I G A L R M a l a r m V 7 1 5 S V R 4 4. 3 + B S D 31 < s i g n a l. h > 0 10. 9 k i l l 0 P O S I X. 1 D

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

TX-NR3030_BAS_Cs_ indd

TX-NR3030_BAS_Cs_ indd TX-NR3030 http://www.onkyo.com/manual/txnr3030/adv/cs.html Cs 1 2 3 Speaker Cable 2 HDMI OUT HDMI IN HDMI OUT HDMI OUT HDMI OUT HDMI OUT 1 DIGITAL OPTICAL OUT AUDIO OUT TV 3 1 5 4 6 1 2 3 3 2 2 4 3 2 5

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

程序 linux/include/linux/math_emu.h 1 /* 2 * linux/include/linux/math_emu.h 3 * 4 * (C) 1991 Linus Torvalds 5 */ 6 #ifndef _LINUX_MATH_EMU_H 7 #de

程序 linux/include/linux/math_emu.h 1 /* 2 * linux/include/linux/math_emu.h 3 * 4 * (C) 1991 Linus Torvalds 5 */ 6 #ifndef _LINUX_MATH_EMU_H 7 #de 程序 14-24 linux/include/linux/math_emu.h 1 /* 2 * linux/include/linux/math_emu.h 3 * 4 * (C) 1991 Linus Torvalds 5 */ 6 #ifndef _LINUX_MATH_EMU_H 7 #define _LINUX_MATH_EMU_H 8 9 #include

More information

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

More information

42 2141601026 2016 11 27 2 1.1............................................. 2 1.2....................................... 2 1.2.1......................................... 2 1.3.............................................

More information

Serial ATA ( nvidia nforce4 Ultra/SLI)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Micro

Serial ATA ( nvidia nforce4 Ultra/SLI)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Micro Serial ATA ( nvidia nforce4 Ultra/SLI)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A... 11 (6) Microsoft Windows 2000... 14 Ác Åé å Serial ATA ( nvidia

More information

自由軟體教學平台

自由軟體教學平台 NCHC Opensource task force DRBL steven@nchc.gov.tw, c00hkl00@nchc.gov.tw National Center for High-Performance Computing http://www.nchc.gov.tw Jan, 2003 1 2003/1/28 ( ) 09:00-10:30 10:40-12:00 Linux 13:00-14:30

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

Windows XP

Windows XP Windows XP What is Windows XP Windows is an Operating System An Operating System is the program that controls the hardware of your computer, and gives you an interface that allows you and other programs

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn Xi III Zebra XI III 1 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn 230V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666

More information

Guide to Install SATA Hard Disks

Guide to Install SATA Hard Disks SATA RAID 1. SATA. 2 1.1 SATA. 2 1.2 SATA 2 2. RAID (RAID 0 / RAID 1 / JBOD).. 4 2.1 RAID. 4 2.2 RAID 5 2.3 RAID 0 6 2.4 RAID 1.. 10 2.5 JBOD.. 16 3. Windows 2000 / Windows XP 20 1. SATA 1.1 SATA Serial

More information

untitled

untitled Lwip Swedish Institute of Computer Science February 20, 2001 Adam Dunkels adam@sics.se (QQ: 10205001) (QQ: 329147) (QQ:3232253) (QQ:3232253) QQ ARM TCPIP LCD10988210 LWIP TCP/IP LWIP LWIP lwip API lwip

More information

1 TPIS TPIS 2 2

1 TPIS TPIS 2 2 1 1 TPIS TPIS 2 2 1. 2. 3. 4. 3 3 4 5 4 TPIS TPIS 6 5 350 Mark Coil F3/F6 350 M 150 M 25 M 7.12M 8 M F3 F6 F4 F7 F8 8M AA 7 350 28V 5V IC HCPL2731 0.5mA 6 8 (TPIS) TPIS 9 7 IC AT89C2051 AT89C2051 CMOS8

More information

EK-STM32F

EK-STM32F STMEVKIT-STM32F10xx8 软 件 开 发 入 门 指 南 目 录 1 EWARM 安 装... 1 1.1 第 一 步 : 在 线 注 册... 1 1.2 第 二 步 : 下 载 软 件... 2 1.3 第 三 步 : 安 装 EWARM... 3 2 基 于 STMEVKIT-STM32F10xx8 的 示 例 代 码 运 行... 6 2.1 GPIO Demo... 6 2.2

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Ác Åé å Serial ATA ( nvidia nforce4 SLI) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c)

Ác Åé å Serial ATA ( nvidia nforce4 SLI) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Serial ATA ( nvidia nforce4 SLI)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A... 11 (6) Microsoft Windows 2000... 14 Ác Åé å Serial ATA ( nvidia nforce4

More information

典型自编教材

典型自编教材 河 南 科 技 大 学 计 算 机 实 验 教 学 中 心 1. 计 算 机 文 化 基 础 实 验 指 导 书 2. 数 据 结 构 实 验 指 导 书 3. 操 作 系 统 实 验 指 导 书 4. 面 向 对 象 程 序 设 计 实 验 指 导 书 5. 数 据 库 原 理 实 验 指 导 书 6. 编 译 原 理 实 验 指 导 书 7. JAVA 程 序 设 计 实 验 指 导 书 8.

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

第6章 信号量,中断和时间

第6章  信号量,中断和时间 6 6 Signal IPC POSIX Unix IPC Ctrl+C 9 IPC Linux Interrupt 5 Linux Linux CPU Linux Linux include/asm-i386/spinlock.h 12582 #ifdef UP SMP UP SMP 10 SMP Linux Nonrealtime SIGSEGVSIGHUP - - 52 6 SIGKILL realtime

More information

uc/os 1

uc/os 1 uc/os 1 uc/os-ii Source Code ANSI C, uc/os-ii 8/16/32 bits microprocessor Preemptive real-time Task 64 Stack Size ROMable (C compiler, assembler and linker/locator) uc/os-ii Mailboxes, Queues, Semaphores,

More information

P3B-F Pentium III/II/Celeron TM

P3B-F Pentium III/II/Celeron TM P3B-F Pentium III/II/Celeron TM 1999 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 13 R PS2 KBMS USB COM1 COM2 JTPWR ATXPWR PWR_FAN CPU_FAN Row 0 1 2 3 4 5 6 7 DSW JP20

More information

Tel:010-62981668-2930 1

Tel:010-62981668-2930  1 Access 93C46 with SPI function V1.0.0 Jan. 31, 2005 http://www.sunplusmcu.com Tel:010-62981668-2930 http://www.sunplusmcu.com E-mail:mcu@sunplus.com.cn 1 0 0...2 1...3 2...4 2.1...4 2.2...5 3...6 3.1 AT93C46...6

More information

<4D F736F F D20B2D9CDB3BFCEB3CCB4FAC2EBD4C4B6C1CABEC0FD2E646F63>

<4D F736F F D20B2D9CDB3BFCEB3CCB4FAC2EBD4C4B6C1CABEC0FD2E646F63> Linux 源代码阅读知识点及要求 说明 :1 本次源代码阅读, 以 Linux 最新的稳定版本 (2.6) 为主 ; 2 源代码下载地址: 在官方站点 www.kernel.org 上最新稳定版本是 2.6.13.2; 在清华的 ftp 上随时都可以下载到 : ftp.tsinghua.edu.cn/mirror/kernel.org/linux/kernel/v2.6/ 3 源代码阅读辅助工具:

More information

WinMDI 28

WinMDI 28 WinMDI WinMDI 2 Region Gate Marker Quadrant Excel FACScan IBM-PC MO WinMDI WinMDI IBM-PC Dr. Joseph Trotter the Scripps Research Institute WinMDI HP PC WinMDI WinMDI PC MS WORD, PowerPoint, Excel, LOTUS

More information

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM Oracle Solaris Studio 12.2 DLight 2010 9 2 2 3 DLight 3 3 6 13 CPU 16 18 21 I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AMP Apache MySQL

More information

概述

概述 Compatibility Report of Red Flag DC Server 4.0 Power by: Product Dept. of Red Flag Date: Mar.31.2003 1...1 2...2 2.1...2 2.2...2 2.3...2 2.4...2 3...3 3.1...3 3.2...15 4...17 1 Red Flag DC Server 4.0 Red

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

Microsoft Word - PS2_linux_guide_cn.doc

Microsoft Word - PS2_linux_guide_cn.doc Linux For $ONY PlayStatioin2 Unofficall General Guide Language: Simplified Chinese First Write By Beter Hans v0.1 Mail: hansb@citiz.net Version: 0.1 本 人 是 菜 鸟 + 小 白 欢 迎 指 正 错 误 之 处, 如 果 您 有 其 他 使 用 心 得

More information

提纲 1 I/O Hardware Polling ( 轮询方式 ) Interrupts ( 中断方式 ) Direct Memory Access (DMA 方式 ) I/O hardware summary 2 Application I/O Interface Block and Chara

提纲 1 I/O Hardware Polling ( 轮询方式 ) Interrupts ( 中断方式 ) Direct Memory Access (DMA 方式 ) I/O hardware summary 2 Application I/O Interface Block and Chara 操作系统原理与设计 第 13 章 IO Systems(IO 管理 ) 陈香兰 中国科学技术大学计算机学院 May 28, 2014 陈香兰 ( 中国科学技术大学计算机学院 ) 操作系统原理与设计 May 28, 2014 1 / 41 提纲 1 I/O Hardware Polling ( 轮询方式 ) Interrupts ( 中断方式 ) Direct Memory Access (DMA 方式

More information

a b c d e f g C2 C1 2

a b c d e f g C2 C1 2 a b c d e f g C2 C1 2 IN1 IN2 0 2 to 1 Mux 1 IN1 IN2 0 2 to 1 Mux 1 Sel= 0 M0 High C2 C1 Sel= 1 M0 Low C2 C1 1 to 2 decoder M1 Low 1 to 2 decoder M1 High 3 BCD 1Hz clk 64Hz BCD 4 4 0 1 2 to 1 Mux sel 4

More information

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice 路 ESW 聯 USB Chapter 9 Applications For Windows Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice USB I/O USB / USB 3 料 2 1 3 路 USB / 列 料 料 料 LED

More information

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt

Microsoft PowerPoint - C15_LECTURE_NOTE_04.ppt MACHINE LANGUAGE CODING AND THE DEBUG SOFTWARE DEVELOPMENT PROGRAM OF THE PC MACHINE LANGUAGE CODING AND THE DEBUG SOFTWARE DEVELOPMENT PROGRAM OF THE PC 4.1 Converting Assembly Language Instructions to

More information

Microsoft Word - InoTouch Editor编程软件手册2012.2.10.doc

Microsoft Word - InoTouch Editor编程软件手册2012.2.10.doc 目 录 第 一 章 关 于 InoTouch Editor 编 程 软 件 的 安 装... - 6-1.1 InoTouch 系 列 HMI 和 InoTouch Editor 软 件 的 简 介... - 6-1.2 安 装 InoTouch Editor 编 程 软 件... - 10-1.3 系 统 连 接 图... - 12-1.4 InoTouch 系 列 人 机 界 面 的 系 统 设

More information

Microsoft Word - 21.doc

Microsoft Word - 21.doc 面向嵌入式 Linux 系统的软中断设计与实现 Design and Implementation of Embedded Linux System Oriented Soft Interrupt ( 中石化管道储运公司潍坊输油处 1 ; 北京联合大学 2 1 ) 李雪莉 2 张兆莉 2 史晓龙 Li,Xueli Zhang,Zhaoli Shi,Xiaolong 摘要本文在分析标准 Linux 内核的软中断机制的演化以及实现原理的基础上,

More information

Microsoft Word - template.doc

Microsoft Word - template.doc HGC efax Service User Guide I. Getting Started Page 1 II. Fax Forward Page 2 4 III. Web Viewing Page 5 7 IV. General Management Page 8 12 V. Help Desk Page 13 VI. Logout Page 13 Page 0 I. Getting Started

More information

OSI OSI 15% 20% OSI OSI ISO International Standard Organization 1984 OSI Open-data System Interface Reference Model OSI OSI OSI OSI ISO Prototype Prot

OSI OSI 15% 20% OSI OSI ISO International Standard Organization 1984 OSI Open-data System Interface Reference Model OSI OSI OSI OSI ISO Prototype Prot OSI OSI OSI 15% 20% OSI OSI ISO International Standard Organization 1984 OSI Open-data System Interface Reference Model OSI OSI OSI OSI ISO Prototype Protocol OSI OSI OSI OSI OSI O S I 2-1 Application

More information