Professional Documents
Culture Documents
)
contents
►Process concepts
►Process scheduling
►Operation on process
►Cooperating process
►Threads
►Interprocess Communication.
►Scheduling Criteria
►Scheduling Algorithm
►Multi-processor scheduling
►Real time Scheduling
►Scheduling Algorithms & Performance Evaluation
Process concepts
► Process requires certain resources such as CPU time, Memory, Files, I/o devices etc are allocated by
Operating System
► OS allocates resources
ready running
Scheduler
I/O or I/O or
dispatch
event event wait
complet
ion
waiting
Process State
►Waiting : Process is waiting for some event like I/O, reception of a signal.
Process state
Process id
Program counter
Scheduling information
registers
Memory limits
2) The parent wait until some of all its Childs have terminated.
Scheduling Queues:
As processes enter the system, they are put into a Job Queue which
consists of all processes in the system
► Ready Queue/List:
► Processes in main memory & are ready to execute
► Ready queue header contains pointers to the first and final PCB in the queue
► Device Queue:
► Separate queue for each device
► New process is to be created which need RAM OR existing process in Ready state or Running state
needs RAM
► When the event for which the processes are waiting, occurs, these swapped
out processes are swapped-in
► CPU Bound: More time is used for computation than generating I/O request e.g. Scientific programs doing lot of
computations
► I/O Bound: Spends more of its time doing I/O than it spends doing computations e.g. a Messaging System
► Memory Bound: These processes are data intensive processes e.g. Database Applications requiring Ram in GB / TB
► Long Term Scheduler carefully selects good process mix so that all three resources are used properly
Cooperating Process
►Multiple processes executed by OS are categorized into two
categories.
1. Independent Processes :
1. Cannot affected by or affect other processes.
2. Doesn’t share any data with other processes.
2. Co Operating Processes :
1. Can affect or be affected by other processes .
2. Shares data with other process
Reasons for Cooperating Processes:
1. Information Sharing: e.g. shared files (app like Railway reservation, WhatsApp,
Facebook).
2. Computation Speedup: A task broken into number of subtasks to run in parallel
(system need multiple processing units like CPU, I/O Channels).
3. Modularity: Dividing system functions into separate processes to run in parallel
(e.g. Schedulers, File I/O, Device & bus drivers).
4. Convenience: An individual user may wish to work on many tasks simultaneously.
Inter-process Communication
► IPC provides a communication mechanism for cooperating processes
► Two standard mechanisms available
1. Shared Memory
2. Message Passing
Shared-Memory Systems
►Requires communicating processes to establish a region in shared memory (typically in address
space of a process).
temporary queue
1. Zero Capacity: Queue can not hold any messages. If Receiver is not ready then sender is blocked
2. Bounded Capacity: Queue has limited capacity to store messages. Sender may be blocked if queue is full.
3. Un-Bounded Capacity: Queue has infinite capacity. Thus sender is never blocked.
Threads
4. Terminates
►Dispatch latency – time it takes for the dispatcher to stop one process
and start another running
Scheduling Criteria
►Deals with selecting a process from Ready Queue (list) for CPU
allocation
►Many different CPU-Scheduling Algorithms
►First come first served Method(FCFS)
►Shortest Job First(SJF)
►Priority
►Round Robin (RR)
First- Come, First-Served (FCFS) Scheduling
P1 24
P2 3
P3 3
Suppose
► that the processes arrive in the order: P1 , P2 , P3
Waiting
► time for P1 = 0; P2 = 24; P3 = 27
Average
► waiting time: (0 + 24 + 27)/3 = 17
FCFS Scheduling (Cont.)
P1 P2 P3 P4
0 8 9 12 18
Assignment solved solution
First come first served Method(FCFS)
►Advantage:
► Simple to implement
► Minimum overload
► Disadvantage
► Unpredictable turn around time
► Associate with each process the length of its next CPU burst
► Use these lengths to schedule the process with the shortest
time
► SJF is optimal – gives minimum average waiting time for a
given set of processes
► Difficulty:: How to know length of next CPU request
2.7.2.1 Example of SJF
Process Arriv Burst Time Arrival Time
P1 0.0 6 0
P2 2.0 8 0
P3 4.0 7 0
P4 5.0 3 0
► SJF scheduling chart
► Ask the user – Then pick process with shortest predicted next
CPU burst
► Automatic ::
► Can be done by using the length of previous CPU bursts
P1 0 8
P2 1 6
P3 2 4
P4 3 2