计算机系 信息处理实验室 Lecture 3 System Mechanisms (1)

Slides:



Advertisements
Similar presentations
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Advertisements

1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 19: I/O, Interupsi 20 November 2002 Bobby Nazief Johny Moningka
CS 141 ChienMay 26, 1999 Interrupt-Driven Input/Output u Last Time –Busses, Arbitration, Interoperability –Polled Input/Output Operations –Inefficiencies.
计算机系 信息处理实验室 Lecture 9 Memory Management(1)
1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
计算机系 信息处理实验室 Lecture 10 Memory Management(2)
计算机系 信息处理实验室 Lecture 5 Startup and Shutdown
CSCI 4717/5717 Computer Architecture
计算机系 信息处理实验室 Leture1 concepts and tools 2005 Spring 陈香兰.
计算机系 信息处理实验室 Lecture 8 Processes, Threads, and Jobs (2)
计算机系 信息处理实验室 Lecture 11 Security
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
Architectural Support for Operating Systems. Announcements Most office hours are finalized Assignments up every Wednesday, due next week CS 415 section.
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Computer System Organization S H Srinivasan
Computer System Structures memory memory controller disk controller disk controller printer controller printer controller tape-drive controller tape-drive.
1/21/2010CSCI 315 Operating Systems Design1 Computer System Structures Notice: The slides for this lecture have been largely based on those accompanying.
计算机系 信息处理实验室 Lecture 14 Cache Manager
计算机系 信息处理实验室 Lecture 2 System architecture
计算机系 信息处理实验室 Lecture 12 I/O System
计算机系 信息处理实验室 Lecture 7 Processes, Threads, and Jobs (1)
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Interrupts Signal that causes the CPU to alter its normal flow on instruction execution ◦ frees CPU from waiting for events ◦ provides control for external.
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
1 Chapter 2: Computer-System Structures  Computer System Operation  I/O Structure  Storage Structure  Storage Hierarchy  Hardware Protection  General.
计算机系 信息处理实验室 Lecture 4 System Mechanisms (2)
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Tami Meredith, Ph.D. CSCI  Devices need CPU access  E.g., NIC has a full buffer it needs to empty  These device needs are often asynchronous.
Windows 2000 System Mechanisms Computing Department, Lancaster University, UK.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
3. System Mechanisms ■ Trap Dispatching - Trap : A Processor`s mechanism for capturing an executing thread an exception or an interrupt occurs and transferring.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Exceptional Control Flow Topics Exceptions except1.ppt CS 105 “Tour of the Black Holes of Computing”
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 2: Computer-System Structures Computer System Architecture and Operation.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
OSes: 2. Structs 1 Operating Systems v Objective –to give a (selective) overview of computer system architectures Certificate Program in Software Development.
بسم الله الرحمن الرحيم MEMORY AND I/O.
9/20/6Lecture 3 - Instruction Set - Al1 Exception Handling.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Input / Output Chapter 9.
Computer System Structures Interrupts
Introduction to Operating Systems
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and exceptions
Microprocessor Systems Design I
CS703 - Advanced Operating Systems
Module 2: Computer-System Structures
Processor Fundamentals
Direct Memory Access Disk and Network transfers: awkward timing:
Architectural Support for OS
Interrupts and Exception Handling
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Chapter 8 I/O.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Architectural Support for OS
Module 2: Computer-System Structures
COMP3221: Microprocessors and Embedded Systems
Module 2: Computer-System Structures
Interrupts and Exception Handling
Presentation transcript:

计算机系 信息处理实验室 Lecture 3 System Mechanisms (1)

计算机系 信息处理实验室 the Inside of Windows Contents Trap dispatching The executive object manager Synchronization System worker threads Local procedure calls (LPCs)

计算机系 信息处理实验室 the Inside of Windows Trap dispatching Interrupt & exception Divert the processor to code outside the normal flow of control Trap: A processor's mechanism for 1.Capturing an executing thread when an exception or an interrupt occurs 2.Transferring control to a fixed location in the operating system

计算机系 信息处理实验室 the Inside of Windows Trap handler a function specific to a particular interrupt or exception

计算机系 信息处理实验室 the Inside of Windows Interrupts vs. exceptions Either hardware or software can generate exceptions and interrupts Interrupt An asynchronous event that is unrelated to what the processor is executing can occur at any time I/O devices, processor clocks, … can be enabled (turned on) or disabled (turned off)

计算机系 信息处理实验室 the Inside of Windows Interrupts vs. exceptions Exception A synchronous condition that results from the execution of a particular instruction Can be reproduced Memory access violations, certain debugger instructions, divide-by-zero errors,… Additionally: System service calls

计算机系 信息处理实验室 the Inside of Windows Stop and continue, how? Trap frame Created by the processor on the kernel stack of the interrupted thread Used to store the execution state of the thread Usually a subset of a thread's complete context

计算机系 信息处理实验室 the Inside of Windows Trap dispatching Front-end trap handling functions Perform general trap handling tasks before and after transferring control to other functions that field the trap Example: The kernel hardware interrupt trap handler The general system service trap handler Unexpected trap handler (KeBugCheckEx)

计算机系 信息处理实验室 the Inside of Windows Trap dispatching Interrupt dispatching Exception dispatching System service call dispatching

计算机系 信息处理实验室 the Inside of Windows Interrupt Dispatching I/O control methods? Polling, interrupt, DMA Interrupt-driven device Allow the operating system to get the maximum use out of the processor by overlapping central processing with I/O operations Example: pointing devices, printers, keyboards, disk drives, and network cards

计算机系 信息处理实验室 the Inside of Windows Interrupt time line for a single process doing output

计算机系 信息处理实验室 the Inside of Windows Interrupt dispatching Interrupt trap handlers For device interrupt --|----> External routine, ISR | (Provided by device drivers) | |---> Internal kernel routine (Provided by kernel)

计算机系 信息处理实验室 the Inside of Windows Hardware Interrupt Processing On x86 systems IRQ interrupt request  interrupt number IDT interrupt dispatch table filled at system boot time OS 8259 M 8259 S device CPU

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing the IDT

计算机系 信息处理实验室 the Inside of Windows Hardware Interrupt Processing PIC: Programmable Interrupt Controller i8259A for uniprocessor systems (IBM PC) <=15 APIC: Advanced Programmable Interrupt Controller i82489 for multiprocessor systems Most new computers <=256

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing the PIC

计算机系 信息处理实验室 the Inside of Windows IRQL (Interrupt request levels) Windows 2000 own interrupt priority scheme Interrupt numbers  IRQL Using IRQL Raise & lower

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing the IRQL

计算机系 信息处理实验室 the Inside of Windows Lazy IRQL: a performance optimization Accessing a PIC is relatively slow Lazy IRQL The changing of the interrupt mask is delayed until a lower-priority interrupt occurs the lower-priority interrupt is postponed until the IRQL is lowered

计算机系 信息处理实验室 the Inside of Windows Mapping interrupts to IRQLs HAL function HalpGetSystemInterruptVector On a uniprocessor system IRQL for Device = 27- interrupt vector

计算机系 信息处理实验室 the Inside of Windows Important restriction Can't wait on an object at DPC/dispatch level or above Only nonpaged memory can be accessed at IRQL DPC/dispatch level or higher If violated, the system crashes with an IRQL_NOT_LESS_OR_EQUAL crash code.

计算机系 信息处理实验室 the Inside of Windows Interrupt objects Contains the information about a device ISR, including the address of the ISR, the IRQL, the entry in the kernel's IDT

计算机系 信息处理实验室 the Inside of Windows Software interrupts Including: Initiating thread dispatching Non-time-critical interrupt processing Handling timer expiration Asynchronously executing a procedure in the context of a particular thread Supporting asynchronous I/O operations

计算机系 信息处理实验室 the Inside of Windows DPC Interrupt routines should exit asap and some knl activity easier when current code has unwound NT uses DPC to schedule non-immediate code, e.g. I/O drivers queue DPCs to complete I/O Knl uses DPC to handle timer expiration Knl uses DPC to reschedule when thread quantum expires Adding DPC to DPC queue causes dispatch/DPC interrupt Dispatch/DPC has low IRQL – deferred if IRQL higher Limits soft real-time capability of NT

计算机系 信息处理实验室 the Inside of Windows Delivering a DPC

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Monitoring Interrupt and DPC Activity

计算机系 信息处理实验室 the Inside of Windows APC (Asynchronous procedure call) interrupts a way for user programs and system code to execute in the context of a particular user thread run at an IRQL less than 2 An APC routine can acquire resources (objects), wait on object handles, incur page faults, and call system services

计算机系 信息处理实验室 the Inside of Windows Kernel mode vs. user mode Kernel mode APC Executive & device driver User mode APC Win32 APIs: ReadFileEx, WriteFileEx, and QueueUserAPC

计算机系 信息处理实验室 the Inside of Windows Exception Dispatching Structured exception handling allows applications to gain control when exceptions occur The application can fix the condition and return, or declare back to the system that the exception isn't recognized The system should continue searching for an exception handler that might process the exception.

计算机系 信息处理实验室 the Inside of Windows X86 Interrupt NumberException 0Divide Error 1DEBUG TRAP 2NMI/NPX Error 3Breakpoint 4Overflow 5BOUND/Print Screen 6Invalid Opcode 7Opcode7NPX Not Available 8Double Exception 9NPX Segment Overrun AInvalid Task State Segment (TSS) BSegment Not Present CStack Fault DDGeneral Protection EEPage Fault FIntel Reserved 10Floating Point 11Alignment Check

计算机系 信息处理实验室 the Inside of Windows Exception dispatcher To find an exception handler that can "dispose of" the exception Some exceptions transparently are handled by kernel A few exceptions are allowed to filter back, untouched, to user mode kernel-mode exceptions If unhandled, are considered fatal operating system errors

计算机系 信息处理实验室 the Inside of Windows Dispatching an exception

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing the Real User Start Address for Win32 Threads

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Unhandled Exceptions

计算机系 信息处理实验室 the Inside of Windows System Service Dispatching On X86 int 0x2e NtWriteFile: mov eax,0x0E; mov ebx,esp; int 0x2E; ret 0x2C;

计算机系 信息处理实验室 the Inside of Windows System service exceptions

计算机系 信息处理实验室 the Inside of Windows System service number to system service translation

计算机系 信息处理实验室 the Inside of Windows System service dispatching

计算机系 信息处理实验室 the Inside of Windows EXPERIMENT Viewing System Service Activity