Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
19 views47 pages

Chapter 3

os
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)
19 views47 pages

Chapter 3

os
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/ 47

PROCESSES

Learning Outcomes:
1. To introduce the notion of a process – a
program in execution, which forms the basis of
all computation.
2. To describe the various features of processes,
including scheduling, creation, and termination.
3. To explore interprocess communication using
shared memory and message passing.
4. To describe communication in client-server
systems.
Topics:
• Process Concepts
• Process Scheduling
• The fork() System Call
• CPU Scheduling algorithms
• Scheduling Algorithms
• Round Robin Scheduling Algorithms
Process Concepts
• A process is the unit of work in a modern
time-sharing system. A process is that set
of instructions brought to life, a dynamic
entity performing actions as prescribed by
the code.
• A thread is a flow of execution through
the process's code, with its own program
counter, system registers, and stack.
Process Concepts
A system therefore consists of a collection of
processes:
• Operating system processes executing
system code, and
• user processes executing user code.
Process Concepts
Operating systems can be classified as one
of three types of systems:
• single-process singlethreaded,
• multiprocess single-threaded,
or multiprocess multithreaded.
Process Concept
A process is a program in execution. The
execution of a process must progress in a
sequential fashion. Definition of process is
the following.
• A process is defined as an entity which
represents the basic unit of work to be
implemented in the system.
The Process
The Process
The Process
Program
• A program by itself is not a process. It is a
static entity made up of program
statement while process is a dynamic
entity. Program contains the instructions
to be executed by processor.
The Process States
Process Control Block
Process Control Block
Process Control Block
Process Control Block
Process Representation in
Linux
• The process control block in the Linux
operating system is represented by the C
structure task struct, which is found in the
<linux/sched.h> include file in the kernel
source-code directory.
Process Representation in
Linux
long state; /* state of the process */
struct sched entity se; /* scheduling information */
struct task struct *parent; /* this process’s parent */
struct list head children; /* this process’s children */
struct files struct *files; /* list of open files */
struct mm struct *mm; /* address space of this process */
Process Representation in
Linux
Process Scheduling
Process scheduling
• is the activity of the process manager that
handles the removal of the running process
from the CPU and the selection of another
process on the basis of a particular strategy.
Scheduling Queues
Ready Queue
• The processes that are residing in main
memory and are ready and waiting to
execute are kept on a list.
Scheduling Queues
Device Queue
• The list of processes waiting for a particular
I/O device.
Scheduling Queues
• Scheduling queues refers to queues of
processes or devices.
Scheduling Queues
Scheduling Queues
Two State Process Model:
Scheduling Queues
Two State Process Model:
Schedulers
The operating system must select, for
scheduling purposes, processes from these
queues in some fashion. The selection process
is carried out by the appropriate scheduler.
Schedulers
• The long-term scheduler, or job scheduler,
selects processes from this pool and loads
them into memory for execution.
Schedulers
• The short-term scheduler, or CPU
scheduler, selects from among the
processes that are ready to execute and
allocates the CPU to one of them.
Schedulers
In general, most processes can be described
as either
• I/O bound or
• CPU bound.
Schedulers
Medium-term scheduler
Schedulers
In many multitasking systems the processor
scheduling subsystem operates on three
levels:
• Long Term Scheduler
• Short Term Scheduler
• Medium Term Scheduler
Schedulers
• dispatching affects processes
– running;
– ready;
– blocked (wait state);
Schedulers
• the medium term scheduling affects processes
– ready-suspended;
– blocked-suspended;
• the long term scheduling affects processes
– new;
– exited
Schedulers
Long Term Scheduler
• It is also called job scheduler.
• Long term scheduler determines which
programs are admitted to the system for
processing.
Schedulers
Simple policies for long term scheduling are:
• Simple First Come First Served (FCFS)
• Priority schemes.
Schedulers
Medium Term Scheduler
Schedulers
Short Term Scheduler
• It is also called the CPU scheduler.
• Short term scheduler also known
as dispatcher, execute most frequently and
makes the fine grained decision of which
process to execute next.
Schedulers
The performance criteria can be stated as:
• Response time
• Turnaround time
• Meeting deadlines
• Predictability
Schedulers
additional scheduling criteria:
• Throughput
• User processor utilization
• Overall processor utilization
• Resource utilization balance
Schedulers
additional criteria to be accounted for arise:
• Fairness
• Enforcing priorities
Schedulers
Three basic issues in short term scheduler design:
• The process switch must be done efficiently,
otherwise the users will suffer from poor
system responsiveness.
• Since many data structures are shared among
processes there must be a consistent method
for allowing data access between them.
Schedulers
Three basic issues in short term scheduler design:
• Since the system manages multiple processes,
each of which assumes the only process
running on the time-shared machine, the
system must choose a scheme in which
processes have a fair share of time, where the
``fairness'' is conditioned by the overall system
policy.
Schedulers
Long Term Scheduler:
It is a job scheduler
Short Term Scheduler:
It is a CPU scheduler
Medium Term Scheduler:
It is a process swapping scheduler.
Schedulers
Long Term Scheduler:
Speed is lesser than short term scheduler
Short Term Scheduler:
Speed is fastest among other two
Medium Term Scheduler:
Speed is in between both short and long term
scheduler.
Schedulers
Long Term Scheduler:
It controls the degree of multiprogramming
Short Term Scheduler:
It provides lesser control over degree of
multiprogramming
Medium Term Scheduler:
It reduces the degree of multiprogramming.
Schedulers
Long Term Scheduler:
It is almost absent or minimal in time sharing
system
Short Term Scheduler:
It is also minimal in time sharing system
Medium Term Scheduler:
It is a part of Time sharing systems.
Schedulers
Long Term Scheduler:
It selects processes from pool and loads them into
memory for execution
Short Term Scheduler:
It selects those processes which are ready to execute
Medium Term Scheduler:
It can re-introduce the process into memory and
execution can be continued.

You might also like