Operating Systems
ECEG-5202
Introduction
Surafel Lemma Abebe (Ph. D.)
Outline
• What is an operating system?
• History of operating systems
• Operating system structures
• Computer system overview
Surafel Lemma Abebe (Ph. D.) 2
What is Operating System?
• Modern computer parts
– Processors + memory + disks + keyboard + …
– Challenge for program developers
• Understanding and managing components
• Optimum use
– Solution
• Operating system
– Provides user programs with a better, simpler, cleaner model of the computer
– Manages all the resources
– Mode of operation
• Kernel mode and User mode
Surafel Lemma Abebe (Ph. D.) 3
What is Operating System?...
• Distinction between kernel and user modes
– Software in user mode can be replaced
– Location of the software
– Complexity and size
– Age
• E.g. Windows 95, 98, and Me were basically one OS
Same for Windows 2000, XP, Vista, Windows 7
Surafel Lemma Abebe (Ph. D.) 4
What is Operating System?...
• What is an OS?
– Software that runs in kernel mode
– A program that acts as an intermediary between a user of a computer and the computer
hardware
– Set of programs that controls a computer
– Software that controls the hardware …. 1960’s definition
• No universally accepted definition
– “Everything a vendor ships when you order an operating system” is a good approximation
• But varies wildly
• Goals of OS
– Execute user programs and make solving user problems easier
– Make the computer system convenient to use
– Use the computer hardware in an efficient manner
Surafel Lemma Abebe (Ph. D.) 5
What is Operating System?...
• Functions (jobs) of OS
– Provide abstract set of resources
• Create good abstractions and then implement and manage the
abstract objects created
– Top-down view
• Abstraction for application programmers (provided by OS)
Vs.
Abstraction for end users (provided by UI)
• Why abstraction?
– Standardization (e.g., device drivers)
– Easy to use functions (e.g., file abstraction)
– To transform the computer hardware into multiple virtual computers
(e.g., processes view of the hardware)
– To enforce security
Surafel Lemma Abebe (Ph. D.) 6
What is Operating System?...
• Functions (jobs) of OS…
– Manage hardware resources
• Provide for an orderly and controlled allocation of the
resources among the various programs wanting them
– Bottom-up view
• Keep track of which programs are using which resource, to
grant resource requests, to account for usage, and to
mediate conflicting requests
• Resource management includes multiplexing (sharing)
• Multiplexing (sharing) resources
– Time multiplexing
– Space multiplexing
Surafel Lemma Abebe (Ph. D.) 7
History of OS
• Development of OS is closely tied to the development of computer
systems
• Map OS generations to computer generation
• First digital computer
– Charles Babbage (1792-1871)
– Analytical engine – never worked properly
– No OS – but he realized the need for software
• Ada Lovelace was the first programmer
• First generation: 1940’s
– No operating system
– Programming languages were unknown
– Uses plug boards (mechanical switches)
– Used by engineers
– Used to solve simple problems
• E.g., Tables of sines and cosines, artillery trajectories
Surafel Lemma Abebe (Ph. D.) 8
History of OS…
• Second generation: 1950’s
– First OS built
– Single-stream batch processing systems
• Programs and data were submitted in groups or batches
• Ran one job at a time
– Used for scientific and engineering
calculations
• E.g., solving partial differential equations
Surafel Lemma Abebe (Ph. D.) 9
History of OS…
• Third generation: 1960’s
– Used integrated circuits
• Major price/performance advantage over 2nd generation machines
– Batch processing systems
– First OS related bugs were introduced
– Features
• Multiprogramming
– Several programs run at the same time sharing the machine, i.e., I/O and CPU
» A job runs until it performs I/O
– Achieved through memory partitioning
• Spooling (simultaneous peripheral operations on line)
– Load jobs from the disk and write outputs to disk
• Time-sharing
– Allowed to multi-program large number of simultaneous interactive users
– MULTICS (MULTiplexed Information and Computing Service)
Surafel Lemma Abebe (Ph. D.) 10
History of OS…
• Fourth generation: 1980 – present
– With advent of Large Scale Integration (LSI) circuits OS
entered the era of microcomputers
– Two OSs dominated
• MS-DOS
– Windows OSs
• UNIX
– Different UNIX flavors such as Linux
– Mac OS X
– GUI introduced
– Network OS
– Distributed OS
Surafel Lemma Abebe (Ph. D.) 11
History of OS…
• Fifth generation: 1990 – to present
– Result of mobile phone development
• From “the brick” to what we have now
– Different OS developed
Surafel Lemma Abebe (Ph. D.) 12
OS Structure
• Monolithic Systems
– Entire OS runs as a single program in kernel mode
– Advantage
• Efficient
– Each procedure in a system is free to call any other procedure
– Disadvantage
• Difficult to manage and understand
– No information hiding
• A crash in a procedure could take down the entire system
– Basic structure:
• Main procedure
• Service procedure, and;
• Utility procedure
– Many support loadable extensions
Surafel Lemma Abebe (Ph. D.) 13
OS Structure…
• Layered Systems
– Organizes OS as a hierarchy of layers
– Examples
• THE system
Layer Function
5 The operator
4 User programs
3 Input/Output management
2 Operator-process communication
1 Memory and drum management
0 Processor allocation and multiprogramming
• MULTICS system
– Uses a series of concentric rings
– Inner rings are more privileged than the outer rings
Surafel Lemma Abebe (Ph. D.) 14
OS Structure…
• Microkernels
– Idea: Achieve high reliability by splitting the OS up into small,
well-defined modules
– The microkernel module will only run in kernel mode
• Compare a bug in a module with a bug in monolithic system
– Example: MINIX
– Another approach to have minimal kernel
• Decoupling policy and mechanism
Surafel Lemma Abebe (Ph. D.) 15
OS Structure…
• Client-server model
– Involves two classes of processes:
• Servers
• Clients
– Message passing is used for communication
Surafel Lemma Abebe (Ph. D.) 16
OS Structure…
• Virtual machines
– Why we need them?
• Minimize cost
– A single machine could run multiple servers, without having a
crash of one server bringing down the rest
• Gain control over the server software
– E.g., in web hosting
• Flexibility
– Running multiple OSes
– Type 1 hypervisor
– Problem
• On x86, trying to execute privileged instructions in user
mode is ignored
• The CPU is not virtualizable
Surafel Lemma Abebe (Ph. D.) 17
OS Structure…
• Virtual machines…
– Solution
• Interpreters
• Disadvantage
– Performance loss
• Solution (1)
– Machine simulators ((b) in the figure)
– Not so fast for commercial purpose
• Solution (2)
– Add a kernel module ((c) in figure)
Surafel Lemma Abebe (Ph. D.) 18
OS Structure…
• Exokernels
– Partition resources and allocate them to virtual
machines
– Makes sure each machine uses its own resources
– Advantage
• Saves a layer mapping
– Tracks the resources assigned to a virtual machine
• Has less overhead
– Keep a virtual machines out of the other virtual machine
space
Surafel Lemma Abebe (Ph. D.) 19
Computer System Overview
• Basic elements
Surafel Lemma Abebe (Ph. D.) 20
Computer System Overview…
• Instruction execution
– Steps involved in instruction processing
• Processor reads (fetches) an instruction from memory
– Loads the instruction into instruction register (IR)
• Execute the instruction
– Instruction cycle
• Processing required for
single instruction
• Reasons for halting program execution
– Processor turned off
– Unrecoverable error occurs
– Program instruction that halts the processors
• Program counter
– Holds the address of the next instruction to be fetched
– After each instruction fetch, it is incremented by one or by what is indicated in
an instruction
Surafel Lemma Abebe (Ph. D.) 21
Computer System Overview…
• Instruction execution…
– Instruction
• Contains bits that specify the action the processor is to take
– Processor interprets instruction and performs the
required action
Action category Description
Processor-memory Data may be transferred from processor to memory or from memory to processor
Processor-I/O Data may be transferred to or from a peripheral device by transferring between
the processor and an I/O module
Data processing Processor may perform some arithmetic or logic operation on data
Control An instruction may specify that the sequence of execution be altered
Surafel Lemma Abebe (Ph. D.) 22
Computer System Overview…
• Instruction execution…
– Example
• Instruction and data are 16bits long
• Opcode (4 bits)
– 0001 = load AC from memory
– 0010 = store AC to memory
– 0101 = add to AC from memory
• Accumulator (AC) = Temporary register
• Memory is organized as a sequence of 16bits
(– hexadecimal is used in figure)
• For simplicity, no MAR and MBR
• Initial PC = 300
• Question
– What does the instruction execution do?
Show all steps of the execution.
• Answer
– Add contents of two memory locations
Surafel Lemma Abebe (Ph. D.) 23
Computer System Overview…
• Interrupts
– Interrupt the normal sequence of the processor
– Used to improve processor utilization
– Interrupts and instruction cycle
Surafel Lemma Abebe (Ph. D.) 24
Computer System Overview…
• Interrupts…
– Interrupt handler routine is usually part of the OS
• Determines the nature of interrupt
– Classes of interrupts
Surafel Lemma Abebe (Ph. D.) 25
Computer System Overview…
• Multiple interrupts
– Two ways
• Disable interrupt
– Interrupt remains pending if another interrupt is being handled
– Advantage
» Simple, interrupts are handled in strict sequential order
– Limitation
» Doesn’t take relative priority into consideration
• Priority based interrupt
– Allows an interrupt of higher priority to cause a lower-priority
interrupt handler to be interrupted
– E.g., interrupt form a printer, a disk, and a communication line
with increasing priorities
Surafel Lemma Abebe (Ph. D.) 26
Computer System Overview…
• Memory Hierarchy
– Design considerations
• How much? How fast? How expensive?
– Tradeoffs/relationships
• Fast access time, greater cost per bit
• Greater capacity, smaller cost per bit
• Greater capacity, slower access speed
– Challenge for design
• Using large-capacity memory while meeting
performance requirements
– Solution
• Memory hierarchy
• As one goes down the hierarchy
– Decreasing cost per bit
– Increasing capacity
– Increasing access time
– Decreasing frequency of access by processor
» Locality of reference
Surafel Lemma Abebe (Ph. D.) 27
Computer System Overview…
• I/O communication techniques
– Three techniques
– Programmed I/O
• Performs the requested action and sets the appropriate bits in the
I/O status register
• Doesn’t interrupt the process after performing the requested
action
• Process has to take active role to determine when I/O instruction
is completed
• Drawback
– Processor has to wait a long time for the I/O module of concern to be
ready
– Processor has to repeatedly check the status of the I/O module
=> Low system performance
Surafel Lemma Abebe (Ph. D.) 28
Computer System Overview…
• I/O communication techniques…
– Interrupt-driven I/O
• I/O module will interrupt the processor and request to
exchange data
• Requires active intervention of the processor to
transfer data between memory and an I/O module
• Drawbacks
– I/O transfer rate is limited by the speed with which the
processor can test and service a device
– Processor is tied up in managing an I/O transfer
Surafel Lemma Abebe (Ph. D.) 29
Computer System Overview…
• I/O communication techniques…
– Direct memory access (DMA)
• Efficient when transferring a large volumes of data is required
• Communication is performed by a separate module, DMA module
• DMA module
– Transfers the entire block of data to or from memory
– Send an interrupt signal to the processor
• Processor communicates with the module only 2 times
– While submitting the read/write job
– While an interrupt signal is sent to the processor
• Competition for the bus with the processor
– Processor executes more slowly during DMA transfer, if the processor
requires access to the bus
• DMA is efficient than both interrupt-driven or programmed I/O
Surafel Lemma Abebe (Ph. D.) 30
Computer System Overview…
• Multicore and multiprocessor organization
– For improved performance and reliability
– Symmetric multiprocessors (SMP)
• SMP characteristics
– There are 2 or more similar processors of comparable capability
– The processors share the same main memory and I/O facilities
– All processors share access to I/O devices
– All processors can perform the same functions
– Controlled by an integrated OS
• Advantages
– Performance
– Availability
– Incremental growth
– Scaling
Surafel Lemma Abebe (Ph. D.) 31
Computer System Overview
…
• Multicore and multiprocessor organization…
– Multicore computers (aka. Chip multiprocessors)
• Combines 2 or more processors (also called core) on a
single piece of silicon (called a die)
• Each core contain all components of a processor
• Motivation
– Improve performance
=> Put multiple processors and a substantial amount of cache
memory on a single chip
Surafel Lemma Abebe (Ph. D.) 32