Operating System Mainframe Systems
It is a program (software) that acts as Batch Systems
an intermediary (interface) between a user of
• First rudimentary operating system.
a computer and the computer hardware.
• Reduce setup time by batching
It provides an environment in which a
similar jobs (that is jobs with
user may execute programs
common needs are batched)
Computer System Components
• machine runs only one application
User- people, machines, other computers
• Automatic job sequencing–
System and Application Programs-define the automatically transfers control from
ways in which the system resources are used one job to another.
to solve the computing problems of the users
• Resident monitor
(compilers, database systems, video games,
business programs). initial control in monitor
control transfers to job
Operating System-Acts as an intermediary
when job completes control
Computer Hardware - provides basic transfers back to monitor
computing resources (CPU, memory, I/O Multiprogrammed Batch Systems
devices).
To ensure that the CPU is not kept idle:
Operating System goals
Several jobs are kept in main memory
1. To provide a convenient environment at the same time; and
2. To use the computer hardware in an The CPU is multiplexed (partitioned)
efficient manner (ensuring good among them.
performance).
Multiprogramming - some commands are
Operating System Views/Perspectives executed from one program, then that
program is suspended, and then some
Resource allocator – manages and allocates
commands are executed from the next
resources.
program, and so on.
Control program – controls the execution of
• Allows the CPU to process multiple
user programs and operations of I/O devices.
programs
Kernel – the one program running at all times
• While one program (job) is waiting for
(all else being application programs).
an I/O operation to complete, the
CPU is switched to execute another
program rather than remaining idle
during I/O time.
• A program is resumed at the point and do not need advanced CPU
where it was suspended when it gets utilization of protection features.
its turn to use the CPU again.
• May run several different types of
operating systems
Time-Sharing Systems–Interactive Multiprocessor systems
Computing
Parallel Systems
• Allow many users to share one
• Multiprocessor systems with more
machine simultaneously
than one CPU in close
• The CPU is multiplexed among communication.
several jobs that are kept in memory
• Tightly coupled system – processors
and on disk (the CPU is allocated to a
share memory and a clock;
job only if the job is in memory).
communication usually takes place
• A job is swapped in and out of through the shared memory.
memory to the disk.
• Advantages of parallel system:
• On-line communication between the
–Increased throughput
user and the system is provided;
–Economical
when the operating system finishes
–Increased reliability
the execution of one command, it
• graceful degradation
seeks the next “control statement”
•
from the user’s keyboard.
• Symmetric multiprocessing (SMP)
• On-line system must be available for
–Each processor runs an
users to access data and code
identical copy of the
(instructions).
operating system.
– Many processes can run at
once without performance
Desktop Systems
deterioration.
• Personal computers – computer – Most modern operating
system dedicated to a single user. systems support SMP
• Asymmetric multiprocessing
• I/O devices – keyboards, mice, display
screens, small printers. – Each processor is assigned a
specific task; master
• User convenience and
processor schedules and
responsiveness.
allocated work to slave
• Can adopt technology developed for processors.
larger operating system’ often – More common in extremely
individuals have sole use of computer large systems
Distributed Systems control systems, and some display
systems.
• Distribute the computation among
several physical processors. • Well-defined fixed-time constraints.
• Loosely coupled system – each • Real-Time systems may be either
processor has its own local memory; hard or soft real-time.
processors communicate with one
• Hard real-time:
another through various
communications lines, such as high- Secondary storage limited or
speed buses or telephone lines. absent, data stored in short
term memory, or read-only
• Advantages of distributed systems.
memory (ROM)
– Resources Sharing
Conflicts with time-sharing
– Computation speed up – load
systems, not supported by
sharing
general-purpose operating
– Reliability
systems.
– Communications
• Soft real-time
• Requires networking infrastructure.
Limited utility in industrial
• Local area networks (LAN) or Wide
control or robotics
area networks (WAN)
• May be either client-server or peer- Useful in applications
to-peer systems. (multimedia, virtual reality)
requiring advanced
Clustered Systems operating-system features.
• Clustering allows two or more
Handheld Systems
systems to share storage.
• Provides high availability. • Personal Digital Assistants (PDAs)
• Asymmetric clustering: one server
• Cellular telephones
runs the application while another
server is on standby mode.
• Symmetric clustering: all N hosts are
Computing Environments
running the application and
monitoring each other. • Traditional computing
• Web-Based Computing
Real-Time Systems
• Embedded Computing
• Often used as control devices in a
dedicated application such as
controlling scientific experiments,
medical imaging systems, industrial
Module 2 Operating System Structures • Trap - software generated interrupt
caused either by an error or a user
request.
Execution sequence:
Interrupt Handling
Fetch Instruction at PC
• Types of interrupt
Decode
Execute (possibly using registers) – Polling
Write results to registers/mem – Vectored interrupt system
PC = Next Instruction(PC) • Incoming interrupts are disabled
Repeat while another interrupt is being
processed to prevent a lost interrupt.
Computer System Organization
I/O Structure
• I/O devices and the CPU execute
concurrently. • Synchronous I/O
• Each device controller is in charge of
wait instruction idles CPU
a particular device type
until next interrupt
– Each device controller has a
no simultaneous I/O
local buffer. I/O is from the
processing, at most one
device to local buffer of
outstanding I/O request
controller
at a time.
• CPU moves data from/to main
memory to/from the local buffers • Asynchronous I/O - After I/O is
• Device controller interrupts CPU on initiated, control returns to user
completion of I/O program without waiting for I/O
completion.
Interrupts System call
Device Status table - holds
• Interrupt transfers control to the
type, address and state for
interrupt service routine
each device
–Interrupt Service Routine: OS indexes into I/O device
Segments of code that table to determine device
determine action to be taken status and modify table entry
for each type of interrupt. to include interrupt.
– Interrupt vector contains the
Direct Memory Access (DMA)
address of service routines.
• OS preserves the state of the CPU • Used for high speed I/O devices able
to transmit information at close to
– stores registers and the
memory speeds.
program counter (address of
interrupted instruction).
• Device controller transfers blocks of 1. User mode - execution done on behalf
data from buffer storage directly to of a user.
main memory without CPU
2. Monitor mode (supervisor/kernel/system
intervention.
mode) - execution done on behalf of
• Only one interrupt is generated per operating system.
block, rather than one per byte (or
I/O Protection
word).
• All I/O instructions are privileged
Storage Structure
instructions.
• Main memory - only large storage
• Must ensure that a user program
media that the CPU can access
could never gain control of the
directly.
computer in monitor mode, for e.g. a
• Secondary storage - extension of user program that as part of its
main memory that has large execution, stores a new address in
nonvolatile storage capacity. the interrupt vector.
Storage Hierarchy Memory Protection
• Storage systems are organized in a • Must provide memory protection at
hierarchy based on least for the interrupt vector and the
interrupt service routines.
– Speed
– Cost • To provide memory protection, add
– Volatility two registers that determine the
• Caching - process of copying range of legal addresses a program
information into faster storage may address.
system; main memory can be viewed
– Base Register - holds smallest
as fast cache for secondary storage.
legal physical memory
address.
– Limit register - contains the
Hardware Protection
size of the range.
Dual-mode operation • Memory outside the defined range is
protected.
• Sharing system resources requires
operating system to ensure that an • When executing in monitor mode,
incorrect program cannot cause the OS has unrestricted access to
other programs to execute both monitor and users’ memory.
incorrectly.
• Provide hardware support to
differentiate between at least two
modes of operation:
CPU Protection Communications-interprocess
and intersystem
• Timer - interrupts computer after
Error Detection-in hardware, I/O
specified period to ensure that OS
devices, user programs
maintains control.
• Services for providing efficient
Timer is decremented every
system operation
clock tick.
When timer reaches a value Resource Allocation - for
of 0, an interrupt occurs. simultaneously executing jobs
• Timer is commonly used to Accounting-for account
implement time sharing. billing and usage statistics
Protection-ensure access to
• Timer is also used to compute the
system resources is controlled
current time.
System Programs
• Load timer is a privileged instruction.
• Convenient environment for program
System Calls
development and execution. User
• Interface between running program view of OS is defined by system
and the OS. programs, not system calls.
– Assembly language
instructions (macros and
subroutines)
– Some higher level languages
allow system calls to be made
directly (e.g. C)
• Passing parameters between a
running program and OS via
registers, memory tables or stack.
Operating System Services
Services that provide user-interfaces
to OS
Program execution-load program
into memory and run it
I/O Operations - since users
cannot execute I/O operations
directly
File System Manipulation - read,
write, create, delete files
Module 3 PROCESSES ready: The process is waiting to be
assigned to a processor.
running: Instructions are being
Process executed.
waiting: The process is waiting for
• It is the unit of work in most systems
some event to occur.
(e.g. time-sharing system);
terminated: The process has finished
• It is a program in execution; process
execution.
execution must progress in
sequential fashion. Program counter contains the memory
• It has a set of associated resources address of the next instruction to be
executed for this process.
Although 2 processes may be associated with
Note: This information must be saved when
the same program, they are considered 2
an interrupt occurs to allow the process to be
separate execution sequences.
continued afterward
What does a process include?
CPU registers, which include: accumulators,
• program counter (specifies the next index registers, stack pointers, general
instruction to be executed) purpose registers,
• stack (contains temporary data e.g.
Note: This information must be saved when
method parameters)
an interrupt occurs to allow the process to be
• data section (contains global
continued afterward
variables)
• text section (program code) Memory-management information includes:
value of the base and limit registers, page
tables, segment tables
Process Control Block (PCB)
I/O status information, which includes: list of
PCB - Representation of a process in the I/O devices allocated to this process, list of
operating system. open files, etc.
Information associated with each process. CPU scheduling information, which includes:
process priority, pointers to scheduling
Process state
queues, scheduling parameters
Program counter
CPU registers Accounting information, which includes:
CPU scheduling information amount of CPU and real time used, time
Memory-management information limits, account numbers, job or process
Accounting information number, etc.
I/O status information
As a process executes, it changes state
new: The process is being created.
As process is created (enters the system), it Schedulers
is put on a job queue.
Long-term scheduler (or job scheduler)
Job queue – set of all processes in the system.
selects which processes should be
• If there is not enough room in the brought into the ready queue.
main memory for all processes in the is invoked very infrequently (seconds,
job queue, job scheduling is done. minutes) (may be slow).
• Long-term scheduler (or job controls the degree of
scheduler) – selects which processes multiprogramming.
should be brought into the ready
Short-term scheduler (or CPU scheduler)
queue.
selects which process should be
As process is loaded in the memory, it is kept executed next and allocates CPU.
in the ready queue. is invoked very frequently
(milliseconds) (must be fast).
Ready queue - contains set of all processes
residing in main memory, ready and waiting I/O – CPU bound Processes
to execute.
• Processes can be described as either:
Short-term scheduler (or CPU scheduler) –
I/O-bound process – spends more
selects which process should be executed
time doing I/O than
(dispatched) next and allocates CPU.
computations, many short CPU
Dispatcher – a module that gives control of bursts.
the CPU to the process selected by the short CPU-bound process – spends
term scheduler more time doing computations;
few very long CPU bursts.
Long-term scheduler should select a good
• Job queue – set of all processes in the
process mix of I/O bound and CPU bound
system.
processes.
• Ready queue – set of all processes
Medium term
residing in main memory, ready and
waiting to execute. an intermediate level queue used in
systems with virtual memory or
• Device queues – set of processes
timesharing;
waiting for an I/O device.
removes processes from the memory
and reintroduced later (swapping)
reduces the degree of multi
programming
Summary Process Creation
• Swapping – in some other time, the • Parent process create children
process can be reintroduced and processes, which, in turn create other
continued where it left off processes, forming a tree of
processes.
• Context Switch – switching the CPU
from one process to another • Resource sharing
• Dispatcher – a module that gives • Parent and children share all
control of the CPU to the process resources.
selected by the short term scheduler • Children share subset of
parent’s resources.
Suspended Processes
• Execution
Processor is faster than I/O so all
• Parent and children execute
processes could be waiting for I/O
concurrently.
Swap these processes to disk to free • Parent waits until children
up more memory terminate.
• Address space
Waiting or blocked state becomes
suspended state when swapped to • Child is a duplicate of parent.
disk • Child has a program loaded
into it (treated as a new
Two new states
process).
Blocked, suspend
Process Termination
Ready, suspend
• Process executes last statement and
Additional States
asks the operating system to decide it
• Ready – process in main memory and (exit).
available for execution
Output data from child to
• Blocked/Waiting – process in main parent (via wait).
memory and awaiting an event Process’ resources are
deallocated by operating
• Blocked/Suspend – process in
system.
secondary memory and awaiting an
event
• Ready/Suspend – process in
secondary memory and available for
execution
• Parent may terminate execution of
children processes (abort).
Child has exceeded allocated
resources.
Task assigned to child is no
longer required.
Parent is exiting.
Operating system
does not allow child to
continue if its parent
terminates.
Cascading termination
Definition of terms
Address space – list of memory locations
from some minimum (usually 0) to some
maximum, which the process can read and
write. It contains the executable program,
program’s data and stack.
System call – interface between operating
system and process. It is function called by an
application to invoke a kernel service.
Interrupt – hardware mechanism that
enables a device to notify the CPU
Module 4 (CPU Scheduling)
* As process is loaded in the memory, it is
kept in the ready queue.
Ready queue - contains set of all processes
residing in main memory, ready and waiting
to execute.