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

Process

Uploaded by

cdhananjay7100
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)
9 views

Process

Uploaded by

cdhananjay7100
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/ 54

PROCESS

PROCESS
▪ A Program in Execution is called as a PROCESS.
▪ An operating system executes a variety of programs:
▪ Batch System – Jobs
▪ Time-Shared Systems – User Programs or Tasks
▪ A Process Includes:
▪ Program Counter
▪ Stack
▪ Data Section

2
PROCESS IN MEMORY

3
PROCESS
▪ Program is a Passive Entity and a Process is an Active Entity.
▪ Process associates PC and a set of other resources with it.
▪ A Program becomes a Process when an executable file is loaded into
memory.
▪ Two Techniques are present for loading Executable Files.
▪ (Double Clicking EXE, Running EXE through Command Prompt)

4
SET OF VALUES HELD BY A PROCESS
▪ Current value of Program Counter (PC)
▪ Contents of the Processors Registers
▪ Value of the Variables
▪ The Process Stack (SP) which typically contains temporary data such
as subroutine parameter, return address, and temporary variables.
▪ A Data Section that contains Global Variables.

5
TWO STATE PROCESS

6
DISADVANTAGE
▪ Dispatcher portion of O/S doesn't know whether process is blocked
due to I/O operation to get completed or process is in ready state to
execute.

7
THREE STATE BLOCK DIAGRAM

8
DRAWBACKS
• CPU performance issues when the CPU is idle and not executing any
process.
• After the process termination, the data or information is not stored
anywhere.

9
PROCESS STATES

10
PROCESS STATES
▪ New State: The Process being created.
▪ Ready State: The Process is waiting to be assigned to a Processor.
▪ Running State: A Process is said to be running if it has the CPU.
▪ Blocked (or Waiting) State: A Process is said to be blocked if it is
waiting for some event to happen.
▪ Terminated State: The Process has finished Execution.

11
VARIOUS 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
▪ Processes migrate among the various queues

12
USING TWO QUEUES

13
MULTIPLE BLOCKED QUEUES

14
SIX-STATE PROCESS MODEL IN OPERATING
SYSTEM

15
PROCESS CONTROL BLOCK (PCB)
Information associated with each Process
• Process State - Running, waiting, etc., as discussed
above.
• Process ID, and parent process ID.
• CPU registers and Program Counter - These need to be
saved and restored when swapping processes in and out
of the CPU.
• CPU-Scheduling information - Such as priority
information and pointers to scheduling queues.
• Memory-Management information - E.g. page tables
or segment tables.
• Accounting information - user and kernel CPU time
consumed, account numbers, limits, etc.
• I/O Status information - Devices allocated, open file
tables, etc. 16
CONTEXT SWITCH

17
PROCESS SCHEDULING DIAGRAM

18
TYPE OF TERM SCHEDULER
▪ Long-Term Scheduler (or Job scheduler) – Selects which Processes
should be brought into the Ready queue

▪ Medium-Term Scheduler – Intermediate Level of Scheduling. Limit


the Multiprogramming and executes Swapping.

▪ Short-Term Scheduler (or CPU scheduler) – Selects which Process


should be executed next and allocates CPU

19
DIFFERENCE BETWEEN SCHEDULERS

20
PLACE OF SCHEDULERS IN THE
PROCESS STATE DIAGRAM

21
PLACE OF SCHEDULERS IN THE
PROCESS STATE DIAGRAM

22
CPU SCHEDULING
▪ CPU Scheduling – Basis of Multiprogrammed Operating Systems.
▪ Multiprogramming is to have some process running at all times, to
maximize CPU Utilization.
▪ Process Execution consists of a cycle of CPU execution and I/O
wait.
▪ All the processes in the ready queue are lined up waiting for a
chance to run on the CPU.
▪ The Records in the QUEUE are PCB of the Processes.

23
CPU – I/O BURST

24
DISPATCHER
▪ Module that gives control of the CPU to the Process selected by the
Short Term Scheduler.
▪ Functions Involved are:
▪ Switching Context.
▪ Switching to User Mode.
▪ Jumping to 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.

25
DISPATCHER
▪ CPU Utilization – Keep the CPU as busy as possible

▪ Throughput – Number 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 Timesharing Environment)

26
OPTIMIZATION CRITERIA
▪ Max CPU Utilization
▪ Max Throughput
----------------------------------------
▪ Min Turnaround Time
▪ Min Waiting Time
▪ Min Response Time

27
28
29
SJF
▪ Associate with each process the length of its next CPU burst. Use
these lengths to schedule the process with the shortest time
▪ Two Schemes:
▪ Non Preemptive – 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 time for a given set
of processes

30
31
32
PRIORITY SCHEDULING
▪ A Priority Number (Integer) is associated with each Process.
▪ The CPU is allocated to the Process with the Highest Priority (Smallest Integer =
highest priority)
▪ Preemptive
▪ Non Preemptive

▪ SJF is a Priority Scheduling where PRIORITY IS THE PREDICTED NEXT CPU BURST
TIME
▪ Problem in Priority scheduling is STARVATION – Low Priority processes may never
execute
▪ Solution for above mentioned Problem is AGING – as time progresses increase the
priority of the process

33
34
35
ROUND ROBIN
▪ Each Process gets a Small Unit of CPU time (Time Quantum).
▪ After this time has elapsed, the PROCESS IS PREEMPTED and added
to the end of the Ready Queue.
▪ If there are n Processes in the Ready Queue and the time quantum is
q, then each process gets at most q time units at once.
▪ PERFORMANCE
▪ q Large → FIFO
▪ q Small → q must be large with respect to Context Switch,
Otherwise overhead is too high

36
37
TIME QUANTUM AND CONTEXT SWITCH

38
TIME QUANTUM AND CONTEXT SWITCH

39
MULTILEVEL QUEUE
▪ Ready queue is partitioned into separate queues, eg:
▪ foreground (interactive),
▪ background (batch)

▪ Process permanently in a given queue

▪ Each queue has its own scheduling algorithm:


▪ foreground –RR,
▪ background –FCFS

▪ Scheduling must be done between the queues:


▪ Fixed priority scheduling; (i.e., serve all from foreground then from background).
▪ Possibility of starvation.

▪ Time slice –each queue gets a certain amount of CPU time which it can schedule amongst its processes; i.e.,
▪ 80% to foreground in RR
▪ 20% to background in FCFS

40
MULTILEVEL QUEUE SCHEDULING

41
MULTILEVEL FEEDBACK QUEUE
▪ Three queues:
▪ Q0–RR with time quantum 8 milliseconds
▪ Q1–RR time quantum 16 milliseconds
▪ Q2–FCFS

▪ Scheduling
▪ A new job enters queue Q0 which is served FCFS
▪ When it gains CPU, job receives 8 milliseconds
▪ If it does not finish in 8 milliseconds, job is moved to queue Q1
▪ At Q1 job is again served FCFS and receives 16 additional milliseconds
▪ If it still does not complete, it is preempted and moved to queue Q2

42
MULTILEVEL FEEDBACK QUEUE

43
THREADS
▪ Application - Set of Multiple Processes
▪ Process – An Executable File (.exe)
▪ Each PROCESS has its own Address Space, CPU Quota, Access to
▪ Hardware Resources and Kernel Resources
▪ THREAD – Function Present within Executable File
▪ Each THREAD has its own PC, Stack , Registers

44
PROCESS THREAD VIEW

45
PROCESS VS THREADS
Aspect Processes Threads
Definition Independent programs with their own memory Lightweight, smaller units of a process, share
space. memory.
Creation Overhead Higher overhead due to separate memory space. Lower overhead as they share the same memory
space.
Isolation Processes are isolated from each other. Threads share the same memory space.
Resource Allocation Each process has its own set of system resources. Threads share resources within the same process.
Independence Processes are more independent of each other. Threads are dependent on each other within a
process.
Failure Impact A failure in one process does not directly affect A failure in one thread can affect others in the
others. same process.
Sychronization Less need from the sychronization, as processes Requires careful synchronization due to shared
are isolated. resources.
Example Use Cases Running multiple independent applications. Multithreading within a single application for
parallelism.
Memory Usage Typically consumes more memory. Consumes less memory compared to processes.

46
USER SPACE & KERNEL SPACE

47
USER SPACE & KERNEL SPACE

48
PURE USER LEVEL

49
PURE KERNEL LEVEL

50
COMBINED

51
COMBINED THREADS

52
SINGLE & MULTI THREADED PROCESS

53
MULTI THREADING MODELS

Many to One One to One Many to Many


54

You might also like