0% found this document useful (0 votes)
4 views

Lecture 2.1 Process Management

The document provides an overview of process management in operating systems, defining a process as an instance of an application in execution and detailing its attributes such as CPU state and memory contents. It discusses the role of the operating system in managing processes, including resource allocation, process states, and scheduling algorithms. Additionally, it highlights the importance of preemptive scheduling and the challenges of effectively managing process execution and resource utilization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 2.1 Process Management

The document provides an overview of process management in operating systems, defining a process as an instance of an application in execution and detailing its attributes such as CPU state and memory contents. It discusses the role of the operating system in managing processes, including resource allocation, process states, and scheduling algorithms. Additionally, it highlights the importance of preemptive scheduling and the challenges of effectively managing process execution and resource utilization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Process Management

MIT 203 Advanced Operating System and Networking

Alvin R. Malicdem, DIT


Professor
What is a process?
• A process is an instance of an application in
execution.
• The application may be a program written by a user,
or a system application.
• Users may run many instances of the same
application at the same time, or run many different
applications.
• The process only exists for the duration of executing
the application.

DMMMSU-MLUC College of Information


2
Technology, Center of Development in I.T.
What is a process? …cont.
• Its CPU state (register values).
– The current state of the CPU is given by the contents of its
registers – IR, PC, SP etc.
• Its address space (memory contents).
– Only a small part of an applications data can be stored in
registers. The rest is in memory.
• Its environment
– A process does not exist in a vacuum. It typically has
connections with other entities, such as Open files that are
used for input and output.

DMMMSU-MLUC College of Information


3
Technology, Center of Development in I.T.
Process Management
• The OS must allocate resources to processes, enable
processes to share and exchange information, protect
the resources of each process from other processes
and enable synchronization among processes.
• To meet these requirements, the OS must maintain a
data structure for each process, which describes the
state and resource ownership of that process, and
which enables the OS to exert control over each
process.

DMMMSU-MLUC College of Information


4
Technology, Center of Development in I.T.
The Process Control Block (PCB)
oWhen a new process is to be added to those
currently being managed, the OS builds a data
structure called a Process control block (PCB)
oThe PCB contains the following:
n identifies the job
n indicates its current status (READY, RUNNING & BLOCKED)
n stores the current instruction counter
n takes a snapshot of the register contents
n indicates required memory locations
n specifies resource needs
n specifies priority if required

DMMMSU-MLUC College of Information


5
Technology, Center of Development in I.T.
Process Creation
• Four common events can lead to the creation
of a process:
– New batch job.
– Interactive logon
– Created by OS.
– Spawned by existing processes, e.g. parent/child.

DMMMSU-MLUC College of Information


6
Technology, Center of Development in I.T.
Process Termination
• Batch job issues halt instruction
• User logs off
• Process executes a service request to terminate
• Error and fault conditions
• Normal completion
• Time limit exceeded
• Memory unavailable
• Others…
DMMMSU-MLUC College of Information
7
Technology, Center of Development in I.T.
Process States
• Processes change state during their execution,
sometimes by themselves (e.g. by making a system
call), and sometimes due to an external event (e.g.
when the CPU gets a timer interrupt).
• READY, RUNNING and BLOCKED
• once a process is created, it can stay in of the three
states

DMMMSU-MLUC College of Information


8
Technology, Center of Development in I.T.
Process State Transition

dispatch
ready

Pre-empt terminated
Event done run

Wait for event


blocked

DMMMSU-MLUC College of Information


9
Technology, Center of Development in I.T.
Types of Processes
• Foreground Process
• Background Process
• I/O-bound process – spends more time doing
I/O than computations, many short CPU bursts
• CPU-bound process – spends more time
doing computations; few very long CPU bursts

DMMMSU-MLUC College of Information


10
Technology, Center of Development in I.T.
Process Concurrency: Terms
• Multitasking — having multiple processes
time slice on the same processor.
• Multiprogramming —having multiple jobs in
the system(either on the same processor, or on
different processors)
• Multiprocessing — using multiple processors
for the same job or system (i.e. parallel
computing).

DMMMSU-MLUC College of Information


11
Technology, Center of Development in I.T.
Multiprogramming
• a system executing many processes concurrently
• multiple processes are handled by the system at the
same time, typically by time slicing
• requires that the processor be allocated to each
process for a period of time and de-allocated at an
appropriate moment
• The stopping of one process and starting (or
restarting) of another process is called a context
switch.
DMMMSU-MLUC College of Information
12
Technology, Center of Development in I.T.
Why use multiprogramming?
• to improve responsiveness, which means that users
will have to wait less (on average) for their jobs to
complete
• to improve hardware utilization
– Applications use one system component at a time
– allows for simultaneous use of several components
• allows for concurrent programming, in which the
multiple processes interact to work on the same
problem

DMMMSU-MLUC College of Information


13
Technology, Center of Development in I.T.
Scheduling
• refers to the way processes are assigned priorities in a
priority queue.
• This assignment is carried out by software known as
a scheduler.
– Scheduler decides the process to run first by using a
scheduling algorithm
– 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

DMMMSU-MLUC College of Information


14
Technology, Center of Development in I.T.
Scheduling Algorithms
• the method by which processes are given access to
system resources, usually processor time.
• The need for a scheduling algorithm arises from the
requirement of most modern systems to execute more
than one process at a time
• Scheduling algorithms are generally only used in a
time slice multiplexing kernel - in order to effectively
load balance a system, the kernel must be able to
suspend execution of threads forcibly in order to
begin execution of the next thread.

DMMMSU-MLUC College of Information


15
Technology, Center of Development in I.T.
Performance Metrics
• CPU Efficiency
• Throughput
• Turnaround time
• Waiting Time
• Response Time
• Fairness

DMMMSU-MLUC College of Information


16
Technology, Center of Development in I.T.
CPU Efficiency
oSometimes referred to also as CPU utilization
nthe average percentage of the hardware (or the
CPU) that is actually used.
nIf the utilization is high, you are getting more
value for the money invested in buying the
computer.
okeeping CPU busy 100% of the time
oMinimize idle times for the CPU

DMMMSU-MLUC College of Information


17
Technology, Center of Development in I.T.
Throughput
• the number of jobs completed in a unit of time.
• If there are more jobs completed, there should
be more happy users.
• Maximize the number of jobs processed per
hour.

DMMMSU-MLUC College of Information


18
Technology, Center of Development in I.T.
Turnaround Time
• the average time from submitting a job until it
terminates.
• This is the sum of the time spent waiting in the
queue, and the time actually running.

DMMMSU-MLUC College of Information


19
Technology, Center of Development in I.T.
Waiting Time
• the time a job waits (in the ready state) until it
runs
• reducing the time a job waits until it runs also
reduces its response time
• As the system has direct control over the
waiting time, but little control over the actual
run time, it should focus on the wait time

DMMMSU-MLUC College of Information


20
Technology, Center of Development in I.T.
Response Time
• Minimize response time by quickly dealing
with interactive requests, and letting batch
requests wait.
• This normalizes all jobs to the same scale: long
jobs can wait more, and don’t count more than
short ones.

DMMMSU-MLUC College of Information


21
Technology, Center of Development in I.T.
Preemptive Scheduling
• A process scheduling strategy in which the
processing of a job is interrupted and the CPU
is transferred to another job. Also called
context switching.
• Temporarily suspend the logically runnable
processes

DMMMSU-MLUC College of Information


22
Technology, Center of Development in I.T.
Non-Preemptive Scheduling
• A job scheduling strategy in which the job
captures the processor and begins execution
and runs uninterrupted until it issues an IO
request or it is finished.
• Run a process to completion

DMMMSU-MLUC College of Information


23
Technology, Center of Development in I.T.
Non-preemptive Scheduling Algo.
• First-come, first-served (FCFS)
• Shortest Job Next (SJN)
• Non preemptive Priority Scheduling

DMMMSU-MLUC College of Information


24
Technology, Center of Development in I.T.
First-Come First-Served (FCFS)
• a service policy whereby the requests of
customers or clients are attended to in the
order that they arrived, without other biases or
preferences.
• behavior: what comes in first is handled first,
what comes in next waits until the first is
finished, etc.

DMMMSU-MLUC College of Information


25
Technology, Center of Development in I.T.
Shortest Job Next (SJN)
• Associate the length of the next CPU burst with each
process
• The job which has the shortest burst time gets the
CPU
• Assign the process with shortest CPU burst
requirement to the CPU
• Specially suitable to batch processing (long term
scheduling)

DMMMSU-MLUC College of Information


26
Technology, Center of Development in I.T.
Priority Scheduling
oMost common method in batch systems, but may
give slow turnaround to some users.
oGives preferential treatment to important jobs.
oJobs with the same priority are treated FCFS.
oPriority could be based on:
n Least amount of memory required
n Least number of peripheral devices needed
n Shorted estimated CPU time
n Time already spent waiting.

DMMMSU-MLUC College of Information


27
Technology, Center of Development in I.T.
Priority Function
oMemory requirements
nImportant due to swapping overhead
oSmaller memory size => Less swapping overhead
oSmaller memory size => More processes can be
serviced
oTimeliness
nDependent upon the urgency of a task
nDeadlines

DMMMSU-MLUC College of Information


28
Technology, Center of Development in I.T.
Priority Function
oTotal service time
nTotal CPU time consumed by the process during its
lifetime
nEquals attained service time when the process
terminates
nHigher priority for shorter processes
nPreferential treatment of shorter processes
reduces the average time a process spends in the
system

DMMMSU-MLUC College of Information


29
Technology, Center of Development in I.T.
Priority Function
oExternal priorities
nDifferentiate between classes of user and system
processes
oInteractive processes => Higher priority
oBatch processes => Lower priority
nAccounting for the resource utilization
oAttained service time
nTotal time when the process is in the running state

DMMMSU-MLUC College of Information


30
Technology, Center of Development in I.T.
Shortest Remaining Time (SRT)
• Preemptive version of shortest job next
scheduling
• Preemptive in nature (only at arrival time)
• The processor is allocated to the job closest to
completion.
• Can’t be implemented on interactive system
because it requires advance knowledge of
required CPU time.
DMMMSU-MLUC College of Information
31
Technology, Center of Development in I.T.
Round Robin (RR)
• Preemptive in nature
• Preemption based on time slices or time quanta; Time
quantum between 10 and 100 milliseconds
• All user processes treated to be at the same priority
• No process is allocated CPU for more than 1
quantum in a row
• Timer interrupt results in context switch and the
process is put at the rear of the ready queue

DMMMSU-MLUC College of Information


32
Technology, Center of Development in I.T.
Round Robin (RR)
oReady queue treated as a circular queue
n New processes added to the rear of the ready queue
n Preempted processes added to the rear of the ready
queue
n Scheduler picks up a process from the head of the
queue and dispatches it with a timer interrupt set
after the time quantum
oCPU burst < 1 quantum ) process releases CPU
voluntarily

DMMMSU-MLUC College of Information


33
Technology, Center of Development in I.T.
Round Robin (RR)
• Large time quantum => FIFO scheduling
• Small time quantum => Large context
switching overhead
• Rule of thumb: 80% of the CPU bursts should
be shorter than the time quantum

DMMMSU-MLUC College of Information


34
Technology, Center of Development in I.T.
Multi-level Feedback Scheduling
• Most general CPU scheduling algorithm
• Not really separate type, but hybrid. Can be:
– Different queues for different priorities
– Put CPU intensive jobs in one queue and IO intensive jobs
in another. Select alternately.
– Put batch in one queue and interactive in another,
(“Foreground and background”) with interactive given
priority.
• Within the queues, jobs are served FCFS. Much
attention has to be paid to “aging”
DMMMSU-MLUC College of Information
35
Technology, Center of Development in I.T.
Multi-level Feedback Scheduling

• n priority levels — priority scheduling between


levels, round-robin within a level
• Quantum size decreases with priority level
• Jobs are demoted to lower priority levels if they
don’t complete within the current quantum

DMMMSU-MLUC College of Information


36
Technology, Center of Development in I.T.
Comparison of scheduling methods
• Average waiting time
• Average turnaround time

DMMMSU-MLUC College of Information


37
Technology, Center of Development in I.T.
Summary
• Scheduling - which is what “resource
management” is in the context of processes - is
a hard problem.
• It requires detailed knowledge, e.g. how long a
job will run, which is typically not available.
And then it turns out to be NP-complete.

DMMMSU-MLUC College of Information


38
Technology, Center of Development in I.T.
Summary
• However, this doesn’t mean that operating
systems can’t do anything. The main idea is to
use preemption.
• This allows the operating system to learn about
the behavior of different jobs, and to
reconsider its decisions periodically.

DMMMSU-MLUC College of Information


39
Technology, Center of Development in I.T.
Summary
• Periodical preemptions are not guaranteed to
improve average response times, but they do.
• The reason is that the distribution of process
runtimes is heavy-tailed.
• This is one of the best examples of a
widespread operating system policy that is
based on an empirical observation about
workloads.

DMMMSU-MLUC College of Information


40
Technology, Center of Development in I.T.
MITF 201 Advanced Operating Systems

END OF LECTURE

DMMMSU-MLUC College of Information


41
Technology, Center of Development in I.T.

You might also like