Chapter 1: Introduction
• What is an operating system?
• Multiprogramming Batched Systems
• Time-Sharing Systems
• Personal-Computer Systems
• Parallel Systems
• Distributed Systems
• Clustered Systems
• Real-Time Systems
Operating System Concepts
1
Chapter 1: Introduction
• Computer System Architecture
• Computer System Operation
• Storage Structure
• Storage Hierarchy
• Hardware Protection
Operating System Concepts
2
1
What is an Operating System?
• A program that acts as an intermediary between a
user of a computer and the computer hardware.
• Operating system goals:
– Execute user programs and make solving user
problems easier.
– Make the computer system convenient to use.
– Use the computer hardware in an efficient
manner.
Operating System Concepts
3
Computer System Components
1. Hardware – provides basic computing
resources (CPU, memory, I/O devices).
2. Operating system – controls and coordinates
the use of the hardware among various
application programs for various users.
3. System & application programs – define the
ways in which the system resources are used
to solve the computing problems of the users
(compilers, database systems, video games,
business programs).
4. Users (people, machines, other computers).
Operating System Concepts
4
2
Abstract View of System Components
Operating System Concepts
5
Operating System Definitions
• Resource allocator – manages and allocates
resources.
• Control program – controls the execution of user
programs and operations of I/O devices.
• Kernel – the one program running at all times (all
else being system and application programs).
Operating System Concepts
6
3
Operating System Memory Layout
Operating System Concepts
7
Multiprogramming Batched Systems
Multiprogramming: several jobs are kept in main memory
at the same time, and the CPU is multiplexed among them
which requires memory management and protection.
Switching
Job Pool between jobs
Disk CPU
Job CPU
Scheduling Scheduling
Operating System Concepts
8
4
Multiprogramming Batched Systems
• The O.S. picks and begins to execute one job from memory.
Once this job needs an I/O operation the O.S. switches to
another job (CPU or O.S. always busy).
• The number of jobs in memory is less than the number of jobs
in disk (Job Pool).
• If several jobs are ready to be brought into memory and there
is not enough room for all of them, then the system choose
jobs among them (Job Scheduling).
• If several jobs are ready to run at the same time, the system
must choose among them (CPU Scheduling).
• Having several programs in memory at the same time requires
memory management.
• In non-multiprogrammed system, CPU sit idle.
• In multiprogramming system, CPU will never be idle.
Operating System Concepts
9
OS Features Needed for Multiprogramming
• I/O routine supplied by the system.
• Memory management – the system must allocate the memory to several
jobs.
• Job scheduling – the system must choose among several jobs ready to run
from Disk.
• CPU scheduling – the system must choose among several jobs ready to
run in memory.
• Allocation of devices.
• Protection – Must protect OS from other programs and programs from
each other.
___________________________________________________
• Two main disadvantages of Multiprogrammed Batched Systems:
– Users cannot interact with their jobs, while executing.
– A programmer cannot modify a program as it executes to study its
behavior.
Operating System Concepts
10
5
Time-Sharing Systems – Interactive Computing
A time-sharing system uses CPU scheduling and
multiprogramming to provide each user with a small portion of
a time-shared computer.
Main Memory
I/O
operations
Interactive O.S.
CPU
User1
Scheduling
Job1
User2 Disk Job2 CPU
Job3
User3
Multiprogramming
Memory Management
Operating System Concepts
11
Time-Sharing Systems–Interactive Computing
• The CPU is multiplexed among several jobs that are kept in
memory and on disk (the CPU is allocated to a job only if the
job is in memory).
• When a job needs an I/O operation, the CPU switches between
jobs. Therefore, the CPU is always busy.
• A job is swapped in and out of memory to the disk which serves
as a back up for main memory.
• On-line communication between the user and the system is
provided; when the operating system finishes the execution of
one command, it seeks the next “control statement” not from a
card reader, but rather from the user’s keyboard.
• On-line system must be available for users to access data and
code.
Operating System Concepts
12
6
Time-Sharing Systems (Cont.)
• Time-Sharing Systems provide the following:
– On-line file system, where the files are on a
collection of disks. Therefore, disk
management must be provided.
– A mechanism for concurrent execution, which
requires CPU scheduling schemes.
– Mechanisms for job synchronization and
communication to ensure orderly execution.
– A mechanism to avoid deadlock - a job waiting
for another job forever.
Operating System Concepts
13
Personal-Computer Systems
• Personal computers – computer system dedicated to a
single user.
• I/O devices – keyboards, mice, display screens, small
printers.
• PC operating systems were neither multi-user nor
multi-tasking.
• The goal of PC operating systems were to maximize
user convenience and responsiveness instead of
maximizing CPU and I/O utilization.
• Examples: Microsoft Windows and Apple Macintosh
Operating System Concepts
14
7
Parallel Systems
• Multiprocessor systems with more than one CPU in close
communication.
• Tightly coupled system – processors share memory and a
clock; communication usually takes place through the
shared memory.
Processor Storage Processor
Shared Memory
I/O Single O.S. I/O
Operating System Concepts
15
Parallel Systems (Cont.)
• Advantages of parallel system (multiprocessor systems):
– Increased throughput – number of processes that are
completed per time unit.
– Economical (for large jobs) - no need to make copies of
data and distribute it among several processors.
– Faster (for large jobs) – divide the work on all processors.
– Increased reliability (fault – tolerant) – For example, if we
have 10 processors working together on a job and one
processor failed, then the remaining 9 processors must
pick up a share of the work of the failed processor. Thus,
the entire system is still working but slower by 10%.
Therefore, multiprocessor systems are reliable.
Operating System Concepts
16
8
Parallel Systems (Cont.)
• Symmetric multiprocessing (SMP) model
– Each processor runs an identical copy of the operating
system.
– Most modern operating systems support SMP, such as
UNIX for Multimax computer.
Symmetric Multiprocessing Architecture
Operating System Concepts
17
Parallel Systems (Cont.)
• Asymmetric multiprocessing model
– Each processor is assigned a specific task; master
processor schedules and allocates work to slave
processors.
Master Storage Slave
I/O
Processor Processor
Asymmetric Multiprocessing Architecture
Operating System Concepts
18
9
Parallel Systems (Cont.)
• Asymmetric multiprocessing model (Cont.):
- Master performs I/O and computations.
- Only master may execute the O.S.
- Slave can execute only user programs.
- If master fails the system cannot perform I/O.
- If slave fails some computations are lost but
still the system can function.
- More common in extremely large systems.
Operating System Concepts
19
Distributed Systems
• Distribute the computation among several physical processors.
• Loosely coupled system – involves connecting 2 or more
independent computer systems via communication link. So,
each processor has its own O.S. and local memory; processors
communicate with one another through various
communications lines (message passing), such as high-speed
buses or telephone lines.
Storage & O.S Storage & O.S
Communication Link
Processor Processor
Message Passing
I/O I/O
Operating System Concepts
20
10
Distributed Systems (Cont.)
• Advantages of distributed systems:
– Resources Sharing – You can share files and
printers.
– Computation speed up – A job can be partitioned
so that each processor can do a portion
concurrently (load sharing).
– Reliability – If one processor failed the rest still can
function with no problem.
– Communications – Such as electronic mail, ftp, etc.
Operating System Concepts
21
Distributed Systems (Cont.)
• Local Area Network (LAN)
• Wide-Area Network (WAN)
• Metropolitan-Area Network (MAN)
• Client-Server Systems:
– Compute-server provides an interface to client to
request services (i.e., database).
– File-server provides interface for clients to store and
retrieve files.
Operating System Concepts
22
11
Client-Server Systems
• General structure of a client-server system:
Operating System Concepts
23
Distributed Systems (Cont.)
• Peer-to-Peer Systems (P2P): Another model of distributed
system
– P2P does not distinguish clients and servers
– Instead all nodes are considered peers
– May each act as client, server or both
– Node must join P2P network: Registers its service with
central lookup service on network, or broadcast request
for service and respond to requests for service via
discovery protocol
– Examples include Napster and Gnutella
Operating System Concepts
24
12
Clustered Systems
• Like multiprocessor systems, but multiple systems working
together:
– Usually sharing storage via a storage-area network (SAN)
– Provides a high-availability service which survives failures
Asymmetric clustering has one machine in hot-standby
mode
Symmetric clustering has multiple nodes running
applications, monitoring each other
– Some clusters are for high-performance computing (HPC)
Applications must be written to use parallelization
Operating System Concepts
25
Real-Time Systems
• Real–Time Systems are characterized by supplying immediate
response. For example, sensors bring data to the computer.
• Often used as a control device in a dedicated application such as
controlling scientific experiments, medical imaging systems,
industrial control systems, and some display systems.
• Well-defined fixed-time constraints.
• Hard real-time system.
– Secondary storage limited or absent, data stored in short-
term memory, or read-only memory (ROM)
– Conflicts with time-sharing systems, not supported by
general-purpose operating systems.
• Soft real-time system
– Limited utility in industrial control or robotics
– Useful in applications (multimedia, virtual reality) requiring
advanced operating-system features.
Operating System Concepts
26
13
Migration of Operating-System Concepts and Features
Operating System Concepts
27
Computer-System Architecture
Operating System Concepts
28
14
Computer-System Operation
• I/O devices and the CPU can execute concurrently.
• Each device controller is in charge of a particular device type.
• Each device controller has a local buffer.
• CPU moves data from/to main memory to/from local buffers
• I/O is done from the device to local buffer of controller.
• Memory controller is used to ensure orderly access to shared
memory. So, its function is to synchronize access to the
shared memory.
• Device controller informs CPU that it has finished its
operation by causing an interrupt.
Operating System Concepts
29
Interrupt Time Line For a Single Process Doing Output
Operating System Concepts
30
15
Storage Structure
• Main memory – only large storage media that the
CPU can access directly. The programs must be in
main memory to be executed.
• Secondary storage – extension of main memory
that provides large nonvolatile storage capacity.
• Magnetic disks – rigid metal or glass platters
covered with magnetic recording material
– Disk surface is logically divided into tracks,
which are subdivided into sectors.
– The disk controller determines the logical
interaction between the device and the
computer.
Operating System Concepts
31
Moving-Head Disk Mechanism
Operating System Concepts
32
16
Magnetic Disk Mechanism
• The two surfaces of a platter are covered with magnetic
material.
• Platter diameters range from 1.8 to 5.25 inches.
• There may be thousands of concentric cylinders in a disk
drive, and each track may contain hundreds of sectors.
• The transfer rate is the rate at which data flow between the
drive and the computer.
• The positioning time (or random access time), consists of
seek time and rotational latency.
• The seek time is the time to move the disk arm to the
desired cylinder.
• The rotational latency is the time for the desired sector to
rotate to the disk head.
Operating System Concepts
33
Storage Structure
• Floppy disks consist of one platter and the head sits
directly on the surface. Its inexpensive, less storage 1.4MB
and slower compare it to the hard disk. Also, it is
removable.
• The load instruction moves a word from main memory to
an internal register, within the CPU for execution.
• The store instruction moves the content of a register to
main memory.
• Can we store the programs and data in main memory
permanently? The answer is no for two reasons:
– Main memory is small to store all programs and data.
– Main memory (RAM) is volatile storage device that
loses its contents when power is turned off or
otherwise lost.
• Therefore, to store all programs and data permanently you
use secondary storage such as hard disk , CD, diskette.
Operating System Concepts
34
17
Storage Hierarchy
• Storage systems organized in hierarchy.
– Speed
– Cost
– Size
– Volatility
• Caching – copying information into faster
storage system; main memory can be viewed
as a last cache for secondary storage.
Operating System Concepts
35
Storage-Device Hierarchy
Size Fast and
Small Expensive
Size Slow
Large and
Cheap
Operating System Concepts
36
18
Storage-Device Hierarchy
• Registers, cache, and main memory are volatile.
• All storage after main memory are non-volatile.
• Caching: Check first cache memory if data not there go to
main memory and copy it into cache under the assumption
that there is a high probability that it will be needed again.
• Data must be moved from secondary storage into main
memory before use.
• Data transfer from cache to CPU and registers is usually a
hardware function with no operating system control.
• Data transfer from disk to memory is usually controlled by
the operating system.
• Cache Coherency and Consistency is the state that exists
in a multiprocessor system, when any shared data is held
by 2 or more caches, and no 2 caches hold different values
of such a shared data simultaneously.
Operating System Concepts
37
Hardware Protection
• Dual-Mode Operation
• I/O Protection
• Memory Protection
Operating System Concepts
38
19
Dual-Mode Operation
• Protection is needed for any shared resource.
• Sharing system resources requires operating system
to ensure that an incorrect program cannot cause
other programs to execute incorrectly.
• Provide hardware support to differentiate between at
least two modes of operations.
[Link] mode – execution done on behalf of a user.
[Link] mode (also supervisor mode or system
mode) – execution done on behalf of operating
system.
Operating System Concepts
39
Dual-Mode Operation (Cont.)
• At system boot time, the hardware starts in monitor
mode. The O.S. is then loaded, and starts user
processes in user mode.
• Whenever, an interrupt occurs, the hardware
switches from user mode to monitor mode.
• Whenever, the O.S. gains control of the computer,
it is in monitor mode.
• If you do not have dual mode then you can wipe or
write over the O.S. Example: MS-DOS for 8088
architecture does not have a dual mode.
• MS-Widows NT and IBM OS/2 take advantage of
dual mode feature and provide greater protection
for the O.S.
Operating System Concepts
40
20
Dual-Mode Operation (Cont.)
• Mode bit added to computer hardware to indicate the
current mode: monitor (0) or user (1).
• When an interrupt or fault occurs hardware switches to
monitor mode.
Interrupt/fault
monitor user
set user mode
• Privileged instructions can be issued only in
monitor mode.
Operating System Concepts
41
I/O Protection
• All I/O instructions are privileged instructions.
• Must ensure that a user program could never
gain control of the computer in monitor.
Operating System Concepts
42
21
Example of System Call to Perform I/O
User of a System Call to
Perform I/O:
• I/O instructions can be
executed by only the O.S.
• To do I/O, a user
program executes a
system call to request that
the O.S. perform I/O.
Operating System Concepts
43
Memory Protection
• We want to protect the O.S. from access by user
programs, and to protect user programs from one
another.
• In order to have memory protection, add two
registers that determine the range of legal
addresses a program may access:
– base register – holds the smallest legal
physical memory address.
– Limit register – contains the size of the range
• Memory outside the defined range is protected.
Operating System Concepts
44
22
A Base and a Limit Register Define a Logical Address Space
Limit register = 300040 - 420940
Operating System Concepts
45
Protection Hardware
• This protection is accomplished by the CPU hardware
comparing every address generated in user mode with the
registers.
• The base and limit registers can be loaded by only the O.S.
Operating System Concepts
46
23