Professional Documents
Culture Documents
Agenda For Today
Agenda For Today
protection )
Operating system components and services
System calls
Lecture Recap
1
Interrupts
Interrupts are signals by external devices,
normally I/O devices. They tell the CPU to stop its
current activities and execute the appropriate part
of the operating system.
2
Interrupt Handing
When the CPU is interrupted it stops what it is
doing
The address of the interrupted instruction is
saved
Called Interrupt Service Routine (ISR)
After the interrupt is serviced, the saved address
is loaded to the Program Counter
The Interrupted computation can resume as
though the interrupt had not occurred.
Different service routines handle different type of
interrupts.
3
Trap
An event generated by CPU.
Divide a number by zero.
To entertain trap, CPU executes trap service
routine.
In case of trap CPU state (address of next
instruction and contents of registers) are not
saved.
Trap service routine terminates the program with
error message.
ISR and Trap service routines are part OS code.
4
Signal
An event sent to a running program or process.
The process can take one of three possible
actions:
i. Ignore the signal
ii. Default action defined by OS
iii. Programmer defined action
5
Hardware Protection
Dual Mode Operation
I/O Protection
Memory Protection
CPU Protection
6
Dual Mode Operation
CPU runs in two modes:
i. User mode – execution done on behalf of a
user.
ii. Kernel mode (also kernel mode or system
mode) – execution done on behalf of
operating system.
The instructions executed in kernel mode are
called privileged instructions.
When an ISR is executing CPU is kernel mode.
7
Dual-Mode Operation …
Mode bit added to computer hardware to indicate
the current mode: Kernel (0) or user (1).
When an interrupt or fault occurs hardware
Kernel user
set user mode
protected.
It is needed in TSS, if not implemented then one
memory address.
Limit register – contains the size of the range
Use of Base and Limit
Register
Hardware Support
CPU Protection
Timer – interrupts computer after specified period
to ensure operating system maintains control.
14
Operating System Services
Error detection and handling
Operating System Services
Interrupt Trap
System Calls
User processes must not be given open access to
the kernel code
The system call interface layer contains entry point
in the kernel code
System call is programming interface to the
services provided by OS.
Types Of System Calls
Process Control
File Management
Device Management
Communications
Information maintenance
System Call Execution
The user program makes a call to a library function.
Library routine puts appropriate parameters at a
well-known place (registers, stack, or a table in
memory).
The trap instruction is executed to change mode
from user to kernel.
Control goes to operating system.
Operating system determines which system call is
to be carried out.
Semantics of System Call
Execution …
Kernel indexes the dispatch table, which
contains pointers to service routines for system
calls.
Service routine is executed and return parameter
or error code placed at well-known places (usually
a CPU register).
Control given back to user program.
Library function executes the instruction following
trap.
System Call …
Process
Library Call
System Call
trap
Dispatch Table
Service
Code
Kernel
Code