CSS 214 Os-5 2021
CSS 214 Os-5 2021
CSS 214 Os-5 2021
MODULE 5
Dr. O. S. Adebayo
&
Mr. Peter Anyaora
Course Outline
• Important interfaces:
• applications can execute only non-privileged
machine instructions, and they may also call upon
the operating system to perform some service for
them.
• The operating system may use privileged
instructions that are not available to applications.
• Various hardware devices may generate interrupts
that lead to the execution of operating system
code.
Operating System Functionality
application
System calls
operating system
non−privileged machine
privileged instructions interrupts
instructions
Hardware
Sequence of actions in OS
1. The operating system executes, and schedules an application
2. The chosen application runs: the CPU executes its (non-privileged)
instructions, and the operating system is not involved at all.
3. The system clock interrupts the CPU, causing it to switch to the clock’s
interrupt handler, which is an operating system function.
4. The clock interrupt handler updates the operating system’s notion of
time, and calls the scheduler to decide what to do next.
5. The operating system scheduler chooses another application to run in
place of the previous one, thus performing a context switch.
6. The chosen application runs directly on the hardware without OS. After
some time, the application performs a system call to read from a file.
7. The system call causes a trap into the OS. The OS sets things up for the
I/O operation
8. The third application runs.
OS Operation
Privilege
• 2 and 3
Non-privilege
• 1 and 4
levels of protection on Intel processors
At the hardware level, Intel processors provide
four levels of protection.
Level 0: The most protected and intended for
use by the kernel.
Level 1: Intended for other, non-kernel parts of
the operating system.
Level 2: Offered for device drivers: needy of
protection from user applications, but not
trusted as much as the operating system proper2
Level 3: The least protected and intended for
use by user applications
Interrupts vs kernel mode
Interrupts cause a switch to kernel mode
Interrupts are special conditions that cause
the CPU not to execute the next instruction.
Instead, it enters kernel mode and executes
an operating system interrupt handler.