Академический Документы
Профессиональный Документы
Культура Документы
Dual-Mode system execution is key
System Call and Interrupts
System and User mode
System mode provides access not available in user
Similar Mechanisms mode to:
Different Policy Goals
OS address space: code and data
Privileged machine instructions:
Copy across User-OS AS boundary
EECS 678
Return-from-Interrupt (reti)
EECS 678 5 Dr. Douglas Niehaus © 2007 EECS 678 6 Dr. Douglas Niehaus © 2007
Transition from User to System Mode Transition from User to System Mode
Program begins (1) as it is executing normally and
calls a system call interface routine (SCIR)
Normal library subroutine call of a routine with the
special purpose of calling a system service
Return address and subroutine arguments (read
frame) are pushed onto the user stack
SCIR does service-specific processing (2)
In this case pushes arguments on stack in
reverse order for convenience and system call
number of requested service
EECS 678 7 Dr. Douglas Niehaus © 2007 EECS 678 8 Dr. Douglas Niehaus © 2007
Transition from User to System Mode Transition from User to System Mode
User stack state is now complete since it holds all
TRAP instruction semantics determined by CPU
information required by the OS routine Instruction Set Architecture (ISA) HW implementation
TRAP instruction (3) typically takes a numeric
Push Trap Frame (TF) on Kernel stack
argument which uniquely identifies the corresponding
Return address in User Space (PC register)
entry in the Interrupt Vector Table (IVT)
Processor Status Word: User mode and other
state information of CPU at time of TRAP or
IVT supports general interrupt handling semantics
interrupt, used for later restoration of user mode
Each entry corresponds to unique interrupt source
IVT entry contains new PSW (OS mode) and new
Many are devices PC entry (handler entry point)
Traps are “software interrupts” using a range of
Same semantics used for all interrupt handlers
IVT entries indexed by TRAP argument
CPU in OS mode and at start of specified handler
EECS 678 9 Dr. Douglas Niehaus © 2007 EECS 678 10 Dr. Douglas Niehaus © 2007
EECS 678 11 Dr. Douglas Niehaus © 2007 EECS 678 12 Dr. Douglas Niehaus © 2007
Execution of System Call in OS Execution of System Call in OS
Execution begins at the start of the generic system
Generic routine begins by determining which system
call handler which: call is being requested (4)
Establishes system call context on the KERNEL
Gets the system call number
mode stack
Consults the corresponding entry in System Call
Calls the appropriate system call routine as a
Table which gives number of arguments and OS
normal subroutine call in OS mode
entry point
OS system call subroutine returns using normal
conventions to this routine as well
Generic routine reads arguments on the USER
Generic routine must use special instructions but it stack, pushing them onto the KERNEL stack
permits all OS syscall routines to be compiled
Note: Argument arrangement on KERNEL stack
normally, using standard compiler conventions match that created by normal subroutine call
EECS 678 13 Dr. Douglas Niehaus © 2007 EECS 678 14 Dr. Douglas Niehaus © 2007
EECS 678 17 Dr. Douglas Niehaus © 2007 EECS 678 18 Dr. Douglas Niehaus © 2007
EECS 678 21 Dr. Douglas Niehaus © 2007 EECS 678 22 Dr. Douglas Niehaus © 2007