INTRODUCTION
TO
OPERATING SYSTEMS
Lecture 2: DESIGNING A PAPER OPERATING SYSTEM
CHRIS STAFF
Dept. of Computer Science and Artificial Intelligence
University of Malta
Lecture Outline
Aims and Objectives
Designing an Operating System
Interacting with the OS
The Virtual Machine
Some Basic Concepts
A hierarchical operating system model
Protecting the Operating System
Summary
Aims and Objectives
- To Design Paper OS to Understand real OSs, By
- Describing Functions and Characteristics of General Purpose OS
- Introduce concept of Virtual Machine
- OS as User Interface (User / Hardware)
- Introduce Basic Concepts
- Hierarchical Operating System Model
Designing an Operating System
What should an OS Do?
- Already looked at briefly in lecture 1
- Basic - OS should take instructions and process them
- How?
By making resources available to enable instructions to be executed
- Stable Environment
- Allow Instructions to have a fair chance of executing (especially in
Multi-User / Multi-Process environment)
- Security and Protection
What Functions will our OS Offer?
- Job Sequencing
- Job Control Language Interpretation
- Error Handling
- I/O Handling
- Interrupt handling
- Scheduling
- Resource Control
- Protection
- User Interface
What characteristics will our OS have?
- Concurrency
- Sharing
- Long-Term Storage
- Nondeterminacy
Other Desirable Characteristics:
- Efficient Performance - Difficult to measure
- Reliable - Difficult because of above
- Easily Maintainable
- Small
Interacting with the OS
- Two Types of User
- Command-Language User
- System-Call User
- Command-Language user issues commands from terminal (or batch file)
- System-Call Users make run-time system calls. Usually embedded in Programs.
- The User-Interface is character-based (DOS, UNIX) or Graphical (X-Windows,
Microsoft Windows, Macintosh) and is used by Command-Language users.
The Virtual Machine
- Raw computer is hardware that is operated by component specific instructions.
E.g., COPY command
- Operating System abstracts from hardware, so different OSs can be implemented
on same Hardware. E.g., UNIX on DOS PCs.
- VM gives users impression that each has complete control of all resources.
- In reality limits on RAM, Disk space, access to some resources (waiting for
others / Unauthorised)
- OS gives impression that computer system is more than the hardware. E.g.,
- handling I/O
- Memory - OS might support Virtual Memory
- Filing System - access via symbolic name, not actual storage address
- Protection and Error Handling - OS provides, not hardware.
- User control of programs - (E.g., Kill, suspend, run) via command-language
Some Basic Concepts
- Process - Instance of a program in execution. User or system generated.
sequence of actions, one of which is being executed or is capable of being
executed.
- Central Processing Unit (CPU/Processor) - executes Processes.

- A single processor can execute only one instruction at a time.
- A Multi-Processor has 2 or more processors, each executing 1 process at a
time.
Parallel (Concurrent) Processing
- Multiprocessing enables several processes to be in a state of execution
concurrently, by sharing system resources.
Resources
- A resource is a component of the computer system for which processes can
compete. E.g., CPU, I/O Devices...
- Shareable Resources - Can be used by many Processes at the same time.
- Non-shareable - Can be used by only one process at a time.
The Interrupt & Interrupt Handler
- Current instruction may be to perform a calculation, comparison, Read
from/write to I/O, branch, Jump, etc.
- Process cannot always continue executing, leaving CPU unused - inefficient
- Issuing Interrupt forces process to relinquish CPU - OS selects another
process.
- Interrupt occurs because current process terminates, performs I/O, makes
system call, expiration of time, no longer best process to execute.
- Interrupt Handled by Interrupt Handler - determines source of
interrupt and services it.
- Interrupts allows many processes to be between creation and termination \ in
execution.
Inter-process Synchronisation
- Nondeterminacy of process execution.
- Processes need to communicate with each other (e.g., to say that they are
waiting for data).
Deadlock
- All processes can compete for the same limited resources
- All processes have an equal chance of controlling resources
- The nondeterminacy of the OS means that Deadlock could occur when two or more
processes are holding non-shareable resources and are waiting for non-shareable
resources that are held by other processes that are waiting for the resources
that are held by the other processes in the chain.

- The Operating System must identify deadlock and deal with it.
A hierarchical operating system model
- OS is Built like an onion

Reasons:
- More Modular - Information Hiding
- Easy to maintain - well-defined functions
The Layers
- 1 - The Kernel/Nucleus. Manages processes.
- 2 - Basic I/O. Manages secondary storage devices.
- 3 - Memory-management. Manages Primary memory.
- 4 - File System. Manages collections of data by symbolic names; long-term
storage facilities; device Independence.
- 5 - Command-Language Interpreter.
Protecting the Operating System
- OS Needs protection because it could be overwritten, modified, etc. which
could destroy OS.
- OS is held in primary memory.
- Boundary Registers hold locations of Upper and Lower areas of OS in Memory.
User accesses are rejected.
- But User needs to make calls to OS. Done in User Mode/State. Reduced
set of OS commands.
- OS or User Program may perform calls to other commands in Supervisor
Mode/State.
- Instructions only executable in Supervisor state are collectively known as
Privileged Instructions.
Summary
- Described Functions and Characteristics of General Purpose OS.
- Introduced the concept of the Virtual Machine
- Looked at OS as a User Interface
- Introduced some Basic Concepts
- Process
- CPU
- Parallel Processing
- Resource
- Interrupt & Interrupt Handler
- Interprocess Communication & Synchronisation
- Deadlock
- Hierarchical OS Model, and the 5 Layers
- Protection
Next Lecture...
The Kernel of the Operating System (1)