0% found this document useful (0 votes)
8 views63 pages

U-1 Os Notes

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

U-1 Os Notes

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

OPERATING SYSTEM

UNIT-1
LET’S RECALL
PROCESS
MANAGEMENT
Process: Thread:
 A process can be thought of as  A thread is the unit of execution within a
a program in execution. process. A process can have anywhere
from just one thread to many threads.
PROCESS STATE
*As a process executes, it changes state.
*The state of a process is defined in part by the current activity of that process.
PROCESS CONTROL BLOCK

Each process is represented in the


operating system by a Process Control
Block
(PCB) also called a task control block.
PROCESS SCHEDULING
The objective of multiprogramming is to have some
process running at all times, to maximize CPU
utilization.

The objective of time sharing is to switch the CPU


among processes so frequently that users can
interact with each program while it is running.
To meet these objectives, the process scheduler selects
an available process (possibly from a set of several
available processes) for program execution on the
CPU.
- For a single-processor system, there will never be
more than one running process.
- If there are more processes, the rest will have to
wait until the CPU is free and can be rescheduled.
CONTEXT SWITCH
Interrupts cause the operating system to change a CPU from
its current task and to run a kernel routine.
 Such operations happen frequently on general-purpose
systems.
When an interrupt occurs, the system needs to
save the current context of the process currently running on the
CPU so that it can restore that context when its processing is
done, essentially suspending the process and then resuming it.
The context is represented in the PCB of the process
 Switching the CPU to another process requires performing a
state save of the current process and a state restore of a different
process.
*Context-switch time is pure overhead, because the
system does no useful work while switching.

*Its speed varies from machine to machine, depending


on the memory speed, the number of registers that must
be copied, and the existence of special instructions
(such as a single instruction to load or store all
registers).

*Typical speeds are a few milliseconds.


INTERPROCESS COMMUNICATION
IPC provides a mechanism to allow processes to communicate
and to synchronize their actions without sharing the same
address space. IPC uses message passing system.
1. Message Passing System
2. Naming
3. Synchronization
4. Buffering
1. MESSAGE PASSING SYSTEM
Messages sent by a process can be of either fixed or variable
size.
If only fixed-sized messages can be sent, the system-level
implementation is straight-forward and task of programming
more difficult. But variable-sized messages require a more
complex system-level implementation, but programming task
becomes easy.
If processes P and Q want to communicate, they must send
message to and receive messages from each other a
communication link must exist between them. The following
are methods for logically implementing a link and the
send/receive operations:
Direct or indirect communication
Symmetric or asymmetric communication
Automatic or explicit buffering
Send by copy or send by reference
Fixed-sized or variable-sized message
2. NAMING
Processes that communicate with each other go through direct
or indirect communication.

Direct Communication
Indirect Communication
Direct Communication
 Each process which needs to communicate must explicitly name the recipient or
sender of the communication. Here the primitives are defined as:
 Send (P, message) - Send a message to process P
 Receive (Q, message) - Receive a message from process Q
 The properties of communication link are: exactly one link exists between each
pair processes. The processes need to know only each other's identity to
communicate.
Indirect Communication
 The messages are sent to and received from mail boxes or ports. Each mail box
has an unique identification. The primitives are:
 Send (A, message) - Send a message to mail box A
 Receive (A, message) - Receive a message from mail box A
 The properties are: A link is established between a pair of processes only if both
members of the pair have a shared mail box. A link may be associated with more
than two processes. A number of different links may exist between each pair of
communicating processes.
3. SYNCHRONIZATION
Message passing may be either blocking or non-blocking
also known as synchronous or asynchronous.
Blocking Send: The sending process is blocked until the
message is received by the receiving process or by the
mail box.
Non blocking Send: The sending process sends the
message and resumes operation.
Blocking Receive: The receiver blocks until a message
is available.
Non blocking Receive: The receiver retrieves either a
valid message or null.
4. BUFFERING
Communicating processes reside in a temporary queue. A queue is
implemented in 3 ways:
Zero Capacity: The queue has maximum length 0. The sender
must block until the recipient receives the message.
Bounded Capacity: The queue has a finite length n. The link
has a finite capacity. If the link is full the sender must block
until space is available in the queue.
Unbounded Capacity: The queue has infinite length. Any
number of messages can wait in it. The sender never blocks.
CPU SCHEDULING
CPU SCHEDULERS
SCHEDULING CRTERIA

MAXIMIZE MINIMIZE
CPU Utilization Turn Around Time
Throughtput Waiting Time
Response Time
CPU UTILIZATION: A Scheduling algorithm should be
designed so that CPU remains busy as possible. It should make
efficient use of CPU
THROUGHPUT: Numbers of processors completed per unit time
ARRIVAL TIME: Time at which the process arrives in the ready
queue
COMPLETION TIME: Time at which the process completes its
execution
BURST TIME: Time required by a process for CPU execution
RESPONSE TIME: The amount of time at takes from when a
request was submitted until the first response is produced
CPU Scheduling Terms and Terminology

TURN AROUND TIME(TAT): Time difference


between completion time and arrival time
TAT=CT-AT
WAITING TIME(WT): Time difference between turn
around time and burst time
WT=TAT-BT
SCHEDULING ALGORITHMS

Non Preemptive Scheduling Preemptive Scheduling


First Come First Serve Round Robin
(FCFS) Multilevel Queue
Shortest Job First (SJF) Multilevel Feedback
Priority Queue
NON-PREEMPTIVE SCHEDULING
In this type of scheduling, a scheduled job always complete
before another scheduling decision is made. Scheduling occurs
only when a process voluntarily enter the wait state or
terminates. The scheduling techniques which are non-
preemptive scheduling are,
FCFS scheduling
SJF scheduling
Priority scheduling
FIRST COME FIRST SERVE (FCFS)
SCHEDULING
This is the simplest scheduling technique which is managed by
FIFO. A process that requests CPU first is allocated the CPU first.
The cpu executes the jobs in the ready queue one by one.

Convey Effect:
If the process with higher burst time arrived before the processes
with smaller burst time. Then, smaller processes have to wait for a
long tme for long rocesses to release the CPU
SHORTEST JOB FIRST SCHEDULING
PRIORITY SCHEDULING

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy