Interrupts, exceptions and system calls

Chapter 2: Interrupts, Exceptions, and System Calls

Labels (space separated): OS


2.1 Startup of the operating system

start up

  • DISK: store the OS
  • BIOS: Basic I/O Processing System
    • Load BootLoader from disk's boot sector (512 bytes) to 0x7cDD, jump to CS:IP=0000:7cDD
  • BootLoader: load OS
    • Load the code and data of the operating system from the hard disk into the memory and jump to the starting address of the OS
  • CS:IP = 0xf000:fff0 (CS: segment register, IP: instruction register)
  • POST (Power On Self Test): Find Graphics Card and Execute BIOS

OS interacts with devices and programs

  • Interface system calls, exceptions, interrupts
  • defs

    • System calls (from the application)
      • The application actively issues a service request to the operating system
    • Exception (from application)
      • Illegal instruction or other bad processing state (such as memory error)
    • Interrupts (from peripherals)
      • Timers and network interrupts from different hardware devices
  • Differences and Features

Types of source processing time response
interrupt Peripherals asynchronous Persistent, transparent to user applications
abnormal Unexpected behavior of the application Synchronize Kill or re-execute unexpected application instructions
system call Application requests to provide services synchronous or asynchronous wait and continue

2.2 OS interrupts, exceptions and system calls

(1) Interruption

hardware

  • Set interrupt flag (CPU initialization)
    • Set interrupt flags for internal and external events
    • ID of the interrupt event

Software (OS)

  • Save the current processing state
  • Interrupt Service Routine Handling
  • clear interrupt flag
  • Restore a previously saved state

(2) Exception: exception number

  • save the scene
  • exception handling
    • kill the program that generated the exception
    • Re-execute the abnormal instruction
  • restore the scene

(3) System call

  • Program access is mainly through high-level API interfaces rather than direct system calls

Overhead across operating system boundaries

  • Overhead in execution time over program calls
  • Overhead:
    • Initialization overhead for establishing the mapping relationship between interrupt/exception/system call numbers and corresponding service routines
    • build kernel stack
    • Validation parameters
    • The kernel mode is mapped to the address space of the user mode, and the page mapping permission is updated
    • Kernel mode independent address space, TLB

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325738927&siteId=291194637