You are on page 1of 14

CIS340 Operating Systems

Summer 2014
Instructor: Dusan Veselinovic
Computer System
Hardware ( CPU, Memory, I/O Devices)
Von Neumann Architecture
Harvard Architecture
Software (System Software, Applications)
Operating System, Compilers, Loaders

What is an Operating System?
From the users point of view:
Interface between a user and hardware resources.
Direct like console & GUI, but also interface between
users application and the system
From systems point of view:
Resource manager of both hardware and software
Resources that need to be managed: Memory, Files, CPU
time, processes, threads, I/O devices
Historical Perspective
No Operating System at all
The system consists of CPU and memory
Binary programs written out as series of 0110 written entirely by the
user. All resource management is done by the programmer
Loading: manual card feed, Scheduling: sign-in sheet
Program runs until it encounters a HALT instruction
Operator = user checks results manually
User must have intimate knowledge of the internal structure of the
system

Historical Perspective cont.
Adding system utilities Software improvement
Instead of machine code, write assembly language and computer
translates it into binary code
Introduction of a Job as a unit of work.
Job consists of:
Loading data into memory
Loading compiler
Running compiler
Loading output of compiler
Running a program



Historical Perspective cont.

Human Operator - Organizational improvement
No change in technology, but an operator controls scheduling, keeps track of
resources etc.
Introduces a need to communicate job steps to the operator.
Problems: Operator doesnt know if a program is, say, stuck in an infinite loop.
CPU may be idle while operator is changing jobs

Historical Perspective cont.


Automatic Job sequencer Hardware improvement (I/O)
Operator batches jobs, AJS feeds them automatically
Problem: Need to communicate job steps between AJS and operator.
Problem: I/O problem (what if someone inserts some data that it is not
supposed to, what if one job reads more data than it is supposed to ? )
Problem: Termination (jobs running too long, infinite loops)
User vs. Supervisor Instructions and
Modes

User vs. Supervisor Instructions
Some instructions must be privileged
User programs should not be allowed to execute such instructions


User vs. Supervisor Mode
User mode: user jobs running in user mode (restricted access)
Supervisor mode : HALT, modify sensitive memory, I/O operations
Switching between modes TRAP instruction



CPU execution cycle

Fetch Instruction from Memory
Decode instruction
Determine if privileged instruction is executed in User Mode (if yes ->
Exception/Trap)
Execute Instruction (e.g. fetch operands from memory and add)
Check for Interrupts (interrupts come asynchronously we dont want to interfere
with execution of an instruction)
Repeat infinitely
TRAP instruction

Special instruction that allows transition from User->Supervisor mode
1) Set mode bit to Supervisor
2) Branch to O.S. trap service routine

Both steps must be executed together and un-separable (otherwise, security could
be compromised)
Going back to User mode ? An instruction executing in User mode.
Operating System executes in Supervisor/Privileged mode
User applications execute in User mode.
Whenever User application needs to do something sensitive, it must ask the O.S.
AJS Example

AJS starts in supervisor mode
Set mode to User
Branch to User1 program
User1 program running in User mode
User1 program issues Trap instruction to HALT (mode changes to Supervisor, branch to AJS)
AJS running in Supervisor mode
Set mode to User
Branch to User2 program
User2 program running in User mode
User2 program issues Trap for I/O operation (mode changes to Supervisor, branch to AJS)
AJS executes Trap service routine for I/O in supervisor mode
I/O operation executing AJS waiting for I/O to complete (!!!!)
I/O operation completes AJS checks result and sets mode to User and returns to User2 program
User2 program running in User mode
User2 program issues Trap instruction to HALT (mode changes to Supervisor, branch to AJS)
AJS running in Supervisor mode
External Interrupts

Unlike TRAP, which is just a (special) instruction, an Interrupt is a hardware
generated event
Interrupts happen asynchronously independent of the normal CPU instruction
execution cycle
Interrupts are serviced by the O.S.
1) change mode to Supervisor
2) branch to the service routine in the O.S.
A timer interrupt can help with the Running too long problem
Other H/W devices and peripherals can and do generate interrupts
Due to similar handling of Traps and interrupts, TRAPS are sometimes called
Software Interrupts e.g. SWI instructions
Disk drive

Hardware improvement
Instead of sequential magnetic tape disk drive
Consists of multiple platters and read-write heads. Each platter has a number of
tracks and sectors. Platters spin.
Data can be read and written out of order, i.e. disks have random access
Latency time: time it takes for the desired sector to come under the position of the
head
Seek time: time it takes to position the head over the desired track (usually much
longer than latency time since disk is spinning very fast)
Main difference between disk and tape: unlike sequential, FIFO processing in
which AJS doesnt have a choice, disks can easily be read out-of-order. Gives an
opportunity for scheduling and choosing which job to run first.
Spooling (Simultaneous Peripheral Operation On-Line): Batch processing of
multiple jobs by copying them to the disk.
Thank you

You might also like