מערכות הפעלה תרגול 9 – פסיקות ב-linux. מערכות הפעלה - תרגול...

Download מערכות הפעלה תרגול 9 – פסיקות ב-Linux. מערכות הפעלה - תרגול 92 (c) ארז חדד 2003 תוכן התרגול מבוא לפסיקות ב-Linux פסיקות ב-IA32:  סוגי הפסיקות  טבלת

Post on 19-Dec-2015

255 views

Category:

Documents

35 download

Embed Size (px)

TRANSCRIPT

  • Slide 1
  • 9 -Linux
  • Slide 2
  • - 92 (c) 2003 -Linux -IA32: (IDT) -IDT -Linux -Linux:
  • Slide 3
  • - 93 (c) 2003 -Linux (1) Interrupt Service Routine. -Linux , . : -
  • Slide 4
  • - 94 (c) 2003 -Linux (2) : -0 IA32 256 0-255 (interrupt vector) ,
  • Slide 5
  • - 95 (c) 2003 -Linux (3) , ( ) , ( nesting )- , -
  • Slide 6
  • - 96 (c) 2003 -Linux (4) -Linux (Kernel Control Path) ( ) -Kernel Mode -Kernel Mode
  • Slide 7
  • - 97 (c) 2003 -IA32: Interrupts " (masking) " -Interrupt Flag (IF), cli -sti " IF NMI Non-Maskable Interrupts ,
  • Slide 8
  • - 98 (c) 2003 -IA32: Interrupts (2) ( [Advanced] Programmable Interrupt Controller [A]PIC ) APIC IRQ0 IRQ7 IRQ11
  • Slide 9
  • - 99 (c) 2003 -IA32: Interrupts (3) IRQ (Interrupt ReQuest) 16-24 IRQ0-IRQ15/IRQ23 (IRQ Sharing) , IRQn . , n+32
  • Slide 10
  • - 910 (c) 2003 -IA32: exceptions (), " " : 1. Faults : -0 , 2. Traps " , " debuggers, breakpoint -trap 3. Aborts : Machine Check
  • Slide 11
  • - 911 (c) 2003 programmed exceptions ( programmed exceptions ) ( software interrupts ) traps , -Linux int 0x80
  • Slide 12
  • - 912 (c) 2003 Interrupt Descriptor Table (1) -IA32 Interrupt Descriptor Table (IDT) , idtr, -IDT " , lidt -IDT " 256 8 interrupt descriptor
  • Slide 13
  • - 913 (c) 2003 Interrupt Descriptor Table (2) : 1. 2. (segment:offset) 3. DPL CPL 1. ( , debugging), 2. ( ) 3 -IDT: 1. Interrupt Gate: -IF 2. Trap Gate: -IF 3. Task Gate: -Linux,
  • Slide 14
  • - 914 (c) 2003 -IDT DPL seg:offs (gate) 0divide_errortrap0 3int3trap3 0general_protectiontrap13 0timerinterrupt32 0diskinterrupt43 3system_calltrap128
  • Slide 15
  • - 915 (c) 2003 -IDT -Linux (1) -IDT " -BIOS Linux , . , setup_idt() : Interrupt Gate ignore_int() "Unknown Interrupt" ( ) DPL=0 setup_idt() -ignore_int() arch/i386/kernel/head.S , -IDT drivers
  • Slide 16
  • - 916 (c) 2003 -IDT -Linux (2) , arch/i386/kernel/traps.c : set_intr_gate(n, addr) interrupt gate n , DPL=0 kcs:addr (kcs -code segment ) set_system_gate(n, addr) system gate (trap gate ) n kcs:addr, DPL=3 debugging 128 (0x80) set_trap_gate(n,addr) trap gate n , kcs:addr -DPL=0
  • Slide 17
  • - 917 (c) 2003 -IDT -Linux (3) trap_init(), arch/i386/kernel/traps.c, -IDT. : set_trap_gate(0, &divide_error);... set_system_gate(4, &overflow);... set_trap_gate(6, &invalid_op);... set_trap_gate(13, &general_protection); set_intr_gate(14, &page_fault); set_trap_gate(16, &coprocessor_error);... set_system_gate(128, &system_call);
  • Slide 18
  • - 918 (c) 2003 -Linux (1) - hardware error code , : handler_name: pushl $0/* only if no handler error code */ pushl $do_handler_name /* C handler function */ jmp error_code error_code (-1) ( - SAVE_ALL) , error_code -do_handler_name hardware error code, ( struct pt_regs *). , error_code -ret_from_exception
  • Slide 19
  • - 919 (c) 2003 -Linux (2) signal -signal - : floating point exception SIGFPE -signal force_sig() kernel/signal.c: force_sig(sig_number, current); -User Mode, signal , -signal .
  • Slide 20
  • - 920 (c) 2003 -Linux : IRQn_interrupt: pushl $n-256 call common_interrupt -common_interrupt, common_interrupt: common_interrupt: SAVE_ALL/* save registers */ call do_IRQ/* handle interrupt */ jmp ret_from_intr/* resume execution */
  • Slide 21
  • - 921 (c) 2003 do_IRQ() do_IRQ(), -C, -APIC handle_IRQ_event() -ISRs arch/i386/kernel/irq.c do_IRQ() : unsigned int do_IRQ(struct pt_regs regs); regs , ( orig_eax) common_interrupt -Linux
  • Slide 22
  • - 922 (c) 2003 -APIC , -APIC "" ( -Linux) -APIC , , "" ( ) , re-entrancy , -APIC -Linux
  • Slide 23
  • - 923 (c) 2003 do_IRQ() (2) do_IRQ(): -APIC " handle_IRQ_event() ISR Interrupt Service Routine ( ) -APIC ( ) -Linux
  • Slide 24
  • - 924 (c) 2003 -ISRs (1) ISR - : ISR ISR -Handle_IRQ_event() ISRs . -ISRs handle_IRQ_event() -ISRs . -Linux
  • Slide 25
  • - 925 (c) 2003 -ISRs (2) handle_IRQ_event() : SA_INTERRUPT -ISR -ISRs -Linux
  • Slide 26
  • - 926 (c) 2003 , (IF ) (: ) ,
  • Slide 27
  • - 927 (c) 2003 1. critical: : -APIC : -ISR . -ISR 2. noncritical: , : -ISR : ( ) 3. noncritical deferred: , , : . (deferrable functions)
  • Slide 28
  • - 928 (c) 2003 -Linux 1. Softirq: , -softirq (re-entrant) 2. Tasklet: , tasklet re-entrant 3. Bottom Halves: tasklets -bottom halves , , bottom halves ( )
  • Slide 29
  • - 929 (c) 2003 -Linux , : do_IRQ() ( ) (kernel thread) . - do_softirq() : ksoftirqd_CPUn n "ps ax"....
  • Slide 30
  • - 930 (c) 2003 (1) ( ) -Linux 32 , segment registers "" " RESTORE_ALL,
  • Slide 31
  • - 931 (c) 2003 -User Mode ( ) ss esp eflags cs eip hardware error code ( 0 ) : (-1) 256 orig_eax " error_code " SAVE_ALL ( , eax ) es ds eax ebp edi esi edx ecx ebx
  • Slide 32
  • - 932 (c) 2003 (3) ( ss:esp, eflags -cs:eip) " ss:esp orig_eax, " " , , SAVE_ALL , , " error_code
  • Slide 33
  • - 933 (c) 2003 (4) RESTORE_ALL: popl %ebx.. popl %es addl 4, %esp iret , - RESTORE_ALL : , -C, . -RESTORE_ALL orig_eax
  • Slide 34
  • - 934 (c) 2003 , , -Linux , need_resched , -User Mode, , signal -User Mode
  • Slide 35
  • - 935 (c) 2003 (1) , , iret , , , , -schedule() signals - ( do_signal()) : - ret_from_exception- -ret_from_intr -ret_from_sys_call , - RESTORE_ALL ,
  • Slide 36
  • - 936 (c) 2003 (2) ret_from_exception: ? RESTORE_ALL ? ret_from_intr:ret_from_sys_call: schedule() signals ? do_signal()

Recommended

View more >