0% found this document useful (0 votes)
5 views64 pages

CA403 OperatingSystem Sybbaca

An operating system acts as an intermediary between users and computer hardware, aiming to execute user programs, enhance convenience, and utilize resources efficiently. It consists of hardware, the operating system itself, application programs, and users, managing resources and controlling program execution. Various types of operating systems include batch systems, time-sharing systems, desktop systems, parallel systems, and distributed systems, each with unique features and functionalities.

Uploaded by

pratibha9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views64 pages

CA403 OperatingSystem Sybbaca

An operating system acts as an intermediary between users and computer hardware, aiming to execute user programs, enhance convenience, and utilize resources efficiently. It consists of hardware, the operating system itself, application programs, and users, managing resources and controlling program execution. Various types of operating systems include batch systems, time-sharing systems, desktop systems, parallel systems, and distributed systems, each with unique features and functionalities.

Uploaded by

pratibha9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 64

What is an Operating

⚫ A program that acts as an


System?
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
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 the various
application programs for the various users.
3.Applications 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).
Operating System Concepts
4.Users (people, machines, other computers).
Abstract View of System
Components

Operating System Concepts


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 application
programs).

Operating System Concepts


Mainframe
Systems
⚫ Reduce setup time by batching
similar jobs
⚫ Automatic job sequencing –
automatically transfers control
from one job to another. First
rudimentary operating system.
⚫ Resident monitor
⚫ initial control in monitor
⚫ control transfers to job
⚫ when job completes control transfers
pack to monitor
Operating System Concepts
Memory Layout for a Simple
Batch System

Operating System Concepts


Multiprogra
Several jobs are kept in main memory at the same

mmed
time, and the CPU is multiplexed among them.

Batch
Systems

Operating System Concepts


OS Features Needed for
Multiprogramming

⚫ I/O routine supplied by the system.


⚫ Memory management – the
system must allocate the memory
to several jobs.
⚫ CPU scheduling – the system must
choose among several jobs ready
to run.
⚫ Allocation of devices.

Operating System Concepts


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).
⚫ A job swapped in and out of memory to
the disk.
⚫ 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” from the user’s
keyboard.
⚫ On-line system must be available for
users to access data and code.
Operating System Concepts
Desktop
⚫ Personal computers – computer system
Systems
dedicated to a single user.
⚫ I/O devices – keyboards, mice, display
screens, small printers.
⚫ User convenience and responsiveness.
⚫ Can adopt technology developed for
larger
operating system’ often individuals have
sole use of computer and do not need
advanced CPU utilization of protection
features.
⚫ May run several different types of
operating systems (Windows,
MacOS, UNIX, Linux)
Operating System Concepts
Parallel
Systems
⚫ Multiprocessor systems with more than
on CPU in close communication.
⚫ Tightly coupled system – processors share
memory and a clock; communication usually
takes place through the shared memory.
⚫ Advantages of parallel system:
⚫ Increased throughput
⚫ Economical
⚫ Increased reliability
⚫ graceful degradation
⚫ fail-soft systems
Operating System Concepts
Parallel Systems
(Cont.)
⚫ Symmetric multiprocessing (SMP)
Each processor runs and identical

copy of the operating system.
⚫ Many processes can run at once
without performance
deterioration.
⚫ Most modern operating systems
support SMP
⚫ Asymmetric multiprocessing
⚫ Each processor is assigned a specific
task; master processor schedules and
allocated work to slave processors.
⚫ More common in extremely large
systems
Operating System Concepts
Symmetric Multiprocessing
Architecture

Operating System Concepts


Distributed
⚫ Distribute the computation among
Systems
several physical processors.
⚫ Loosely coupled system – each processor
has its own local memory; processors
communicate with one another through
various communications lines, such as
high-speed buses or telephone lines.
⚫ Advantages of distributed systems.
⚫ Resources Sharing
⚫ Computation speed up – load sharing
⚫ Reliability
⚫ Communications

Operating System Concepts


Computer-System
Architecture

Operating System Concepts


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 from the device to local buffer of
controller.
⚫ Device controller informs CPU that it has
Operating System Concepts

finished its operation by causing an


Common Functions of Interrupts
⚫ Interrupt transfers control to the interrupt
service routine generally, through the
interrupt vector, which contains the
addresses of all the service routines.
⚫ Interrupt architecture must save the
address of the interrupted instruction.
⚫ Incoming interrupts are disabled while
another interrupt is being processed to
prevent a lost interrupt.
⚫ A trap is a software-generated interrupt
Operating System Concepts
caused either by an error or a user request.
Interrupt
Handling
⚫ The operating system preserves the state
of the CPU by storing registers and the
program counter.
⚫ Determines which type of interrupt has
occurred:
⚫ polling
⚫ vectored interrupt system
⚫ Separate segments of code determine
what action should be taken for each
type of interrupt
Operating System Concepts
Interrupt Time Line For a Single Process
Doing Output

Operating System Concepts


I/O
Structure
⚫ After I/O starts, control returns to user
program only
upon I/O completion.
⚫ Wait instruction idles the CPU until the next
interrupt
⚫ Wait loop (contention for memory access).
⚫ At most one I/O request is outstanding at a
time, no simultaneous I/O processing.
⚫ After I/O starts, control returns to user
program without waiting for I/O
completion.
⚫ System call – request to the operating
system to allow user to wait for I/O
completion.
⚫ Device-status table contains entry for each
I/O device indicating its type, address, and
state.
⚫ Operating system indexes into I/O device
table to
determine device status and to modify table
entry to
Operating System Concepts

include interrupt.
Two I/O
Methods
Asynchrono
us

Synchronous

Operating System Concepts


Device-Status
Table

Operating System Concepts


Direct Memory Access Structure
⚫ Used for high-speed I/O devices able to
transmit information at close to memory
speeds.
⚫ Device controller transfers blocks of data
from buffer storage directly to main
memory without CPU intervention.
⚫ Only on interrupt is generated per block,
rather than the one interrupt per byte.

Operating System Concepts


Storage
Structure
⚫ Main memory – only large storage media that
the CPU can access directly.
⚫ 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.
Operating System Concepts
⚫ The disk controller determines the logical
interaction between the device and the
Moving-Head Disk
Mechanism

Operating System Concepts


Storage
Hierarchy
⚫ Storage systems organized in hierarchy.
⚫ Speed
⚫ Cost
⚫ Volatility
⚫ Caching – copying information into faster
storage system; main memory can be viewed
as a last cache for secondary storage.

Operating System Concepts


Storage-Device
Hierarchy

Operating System Concepts


Caching
⚫ Use of high-speed memory to hold recently-
accessed data.
⚫ Requires a cache management policy.
⚫ Caching introduces another level in storage
hierarchy. This requires data that is
simultaneously stored in more than one level
to be consistent.

Operating System Concepts


Migration of A From Disk to
Register

Operating System Concepts


Hardware
Protection
⚫ Dual-Mode
Operation
⚫ I/O Protection
⚫ Memory
Protection
⚫ CPU Protection

Operating System Concepts


Process
⚫ AnConcept
operating system executes a
variety of programs:
⚫ Batch system – jobs
⚫ Time-shared systems – user
programs or tasks
⚫ Textbook uses the terms job and
process almost
interchangeably.
⚫ Process – a program in execution;
process execution must progress in
sequential fashion.
⚫ A process includes:
⚫ program counter
⚫ stack
⚫ data section
Operating System Concepts
Process
State
⚫ As a process executes, it changes state
⚫ new: The process is being created.
⚫ running: Instructions are being
executed.
⚫ waiting: The process is waiting for
some event to occur.
⚫ ready: The process is waiting to be
assigned to a process.
⚫ terminated: The process has finished
execution.

Operating System Concepts


Diagram of Process
State

Operating System Concepts


Process Control Block
(PCB)
Information associated with each
process.
⚫ Process state
⚫ Program counter
⚫ CPU registers
⚫ CPU scheduling information
⚫ Memory-management
information
⚫ Accounting information
⚫ I/O status information
Operating System Concepts
Process Control Block
(PCB)

Operating System Concepts


CPU Switch From Process to
Process

Operating System Concepts


Process Scheduling Queues
⚫ Job queue – set of all processes in the
system.
⚫ Ready queue – set of all processes residing
in main
memory, ready and waiting to execute.
⚫ Device queues – set of processes waiting
for an I/O device.
⚫ Process migration between the various
queues.

Operating System Concepts


Ready Queue And Various I/O Device
Queues

Operating System Concepts


Representation of Process
Scheduling

Operating System Concepts


Schedul

ers
Long-term scheduler (or job scheduler) –
selects which processes should be brought
into the ready queue.
⚫ Short-term scheduler (or CPU scheduler) –
selects which
process should be executed next and allocates
CPU.

Operating System Concepts


Addition of Medium Term
Scheduling

Operating System Concepts


Schedulers
(Cont.)
⚫ Short-term scheduler is invoked very
frequently (milliseconds)  (must be
fast).
⚫ Long-term scheduler is invoked very
infrequently (seconds, minutes)  (may
be slow).
⚫ The long-term scheduler controls the
degree of multiprogramming.
⚫ Processes can be described as either:
⚫ I/O-bound process – spends more time doing
I/O than computations, many short CPU
bursts.
Operating System Concepts

⚫ CPU-bound process – spends more


Context
⚫ WhenSwitch
CPU switches to another process,
the system must save the state of the
old process and load the saved state for
the new process.
⚫ Context-switch time is overhead; the
system does no useful work while
switching.
⚫ Time dependent on hardware support.

Operating System Concepts


Process
Creation
⚫ Parent process create children processes,
which, in turn create other processes,
forming a tree of processes.
⚫ Resource sharing
⚫ Parent and children share all resources.
⚫ Children share subset of parent’s
resources.
⚫ Parent and child share no resources.
⚫ Execution
⚫ Parent and children execute concurrently.
⚫ Parent waits until children terminate.
Operating System Concepts
Process Creation
(Cont.)
⚫ Address space
⚫ Child duplicate of parent.
⚫ Child has a program loaded into it.
⚫ UNIX examples
⚫ fork system call creates new process
⚫ exec system call used after a fork to replace
the process’
memory space with a new program.

Operating System Concepts


Processes Tree on a UNIX
System

Operating System Concepts


Process
Termination
⚫ Process executes last statement and asks the
operating
system to decide it (exit).
⚫ Output data from child to parent (via wait).
⚫ Process’ resources are deallocated by
operating system.
⚫ 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 Concepts
⚫ Operating system does not allow child to continue if
its parent terminates.
Basic
Concepts
⚫ Maximum CPU utilization
obtained with multiprogramming
⚫ CPU–I/O Burst Cycle – Process
execution consists of a
cycle of CPU execution and I/O
wait.
⚫ CPU burst distribution

Operating System Concepts


Alternating Sequence of CPU And
I/O Bursts

Operating System Concepts


Histogram of CPU-burst
Times

Operating System Concepts


CPU
Scheduler
⚫ Selects from among the processes in memory that
are ready
to execute, and allocates the CPU to one of them.
⚫ CPU scheduling decisions may take place when a
process:
1.Switches from running to waiting state.
2.Switches from running to ready state.
3.Switches from waiting to ready.
4.Terminates.
⚫ Scheduling under 1 and 4 is nonpreemptive.
⚫ All other scheduling is preemptive.
Operating System Concepts
Dispatcher
⚫ Dispatcher module gives control of the
CPU to the process selected by the short-
term scheduler; this involves:
⚫ switching context
⚫ switching to user mode
⚫ jumping to the proper location in the user
program to restart that program
⚫ Dispatch latency – time it takes for the
dispatcher to stop one process and start
another running.
Operating System Concepts
Scheduling
Criteria
⚫ CPU utilization – keep the CPU as
busy as possible
⚫ Throughput – # of processes that
complete their execution per time unit
⚫ Turnaround time – amount of time to
execute a particular process
⚫ Waiting time – amount of time a
process has been
waiting in the ready queue
⚫ Response time – amount of time it
takes from when a request was
submitted until the first response is
produced, not output (for
time- sharing environment)
Operating System Concepts
Optimization
Criteria
⚫ Max CPU
utilization
⚫ Max throughput
⚫ Min turnaround
time
⚫ Min waiting time
⚫ Min response
time

Operating System Concepts


First-Come, First-Served (FCFS)
Scheduling
Proces Burst
s Time
P1 24
P2 3
⚫ Suppose that the processes arrive in the order:
P1 , P2 , P3 P3 3
The Gantt Chart for the schedule is:
P1 P2 P3

3
⚫ Wa0iting time for P1 = 0; P2 0
= 2424; P3 = 2277
⚫ Average waiting time: (0 + 24
+ 27)/3 = 17
Operating System Concepts
FCFS Scheduling
(Cont.)
Suppose that the processes arrive in
the order 2
P2 P3P P1
3
1
0
t chart3 for, the
P6 3
0
schedule is:
,P
⚫ Waiting time for P1 = 6; P2 = 0; P3 = 3
.
⚫ Average waiting time:(6 + 0 + 3)/3 = 3
⚫ The Gant
⚫ Much better than previous case.
⚫ Convoy effect short process behind long
Operating System Concepts

process
Shortest-Job-First (SJR) Scheduling
⚫ Associate with each process the length of its
next CPU burst. Use these lengths to schedule
the process with the shortest time.
⚫ Two schemes:
⚫ nonpreemptive – once CPU given to the process it
cannot be
preempted until completes its CPU burst.
⚫ preemptive – if a new process arrives with CPU
burst length less than remaining time of current
executing process, preempt. This scheme is
know as the
Shortest-Remaining-Time-First (SRTF).
⚫ SJF is optimal – gives minimum average waiting
Operating System Concepts

time for a given set of processes.


Example of Non-
Process Arrival Burst Time
Preemptive
Time
P SJF
0.0
7
1
P2 4
2.0
P3 1
4.0
P4 4
⚫ SJF ( 5.0
non- P1 P3 P2 P4
preemptive)
0 3 7 8 12 16

⚫ Average waiting time = (0 + 6 + 3


+ 7)/4 - 4
Operating System Concepts
Example of
Preemptive
Process
P 0. SJF
Arrival Time Burst Time
 7
1 0  4
P 2.  1
2
0
 4
⚫ SJF preemptiv
P 4.
( e) P1 P2 P3 0P2 P4 P1
3
0 P
2 4 5 5. 7 1 1
0 1 6
4

⚫ Average waiting time = (9 + 1 + 0


+2)/4 - 3
Operating System Concepts
Determining Length of
Next CPU Burst
⚫ Can only estimate the length.
⚫ Can be done by using the length of
previous CPU burst1s., tun sianctguael
lxepngohnt oef nntth CiaPlUabvuersrtaging.
2. n1  predicted value for the next CPU burst
3. , 0   1
4. Define :

n1  tn  1n .

Operating System Concepts

You might also like