Professional Documents
Culture Documents
Process Concept
A process will need certain resources—such as CPU time, memory, files, and
I/O devices —to accomplish its task.
ran, most modern operating systems now support processes that have multiple
threads.
The operating system is responsible for the following activities in connection with
process and thread management:
scheduling of processes;
synchronization, communication,
A process includes:
Process state
Program counter
CPU registers
Memory-management information
Accounting information
fast)
the state of the old process and load the saved state for the new
process
the value of the CPU registers, the process state, and memory-
management information.
Interprocess Communication (IPC)
It shares with other threads belonging to the same process its code
section, data section, and other operating-system resources, such as
open files and signals.
a process has multiple threads of control, it can perform more than one
task at a time.
Single and Multithreaded Processes
CPU Scheduling
others must wait until the CPU is free and can be rescheduled.
Selects from among the processes in memory that are ready to execute, and
allocates the CPU to one of them
4. Terminates (nonpreemptive)
Dispatcher
switching context
Dispatch latency – time it takes for the dispatcher to stop one 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 time-sharing environment)
Optimization Criteria
Max throughput
Priority Scheduling
P1 24
P2 3
P3 3
P1 P2 P3
0 24 27 30
P 2 , P3 , P1
P2 P3 P1
0 3 6 30
Associate with each process the length of its next CPU burst. Use these
lengths to schedule the process with the shortest time
Two schemes:
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
Example of Non-Preemptive SJF
P4 P1 P3 P2
0 3 9 16 24
P1 P3 P2 P4
0 3 7 8 12 16
P1 P2 P3 P2 P4 P1
0 2 4 5 7 11 16
The CPU is allocated to the process with the highest priority (smallest integer
highest priority)
Preemptive
nonpreemptive
SJF is a priority scheduling where priority is the predicted next CPU burst time
Each process gets a small unit of CPU time (time quantum), usually 10-100
milliseconds. After this time has elapsed, the process is preempted and added
to the end of the ready queue.
Process Burst Time
P1 53
P2 17
P3 68
P4 24
The Gantt chart is:
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
P0 P1
request
use
release
Deadlock Characterization
Hold and wait: a process holding at least one resource is waiting to acquire
additional resources held by other processes.
Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that
P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is
held by P2, …, Pn–1 is waiting for a resource that is held by
Pn, and Pn is waiting for a resource that is held by P0.
Resource-Allocation Graph
P = {P1, P2, …, Pn}, the set consisting of all the processes in the system.
R = {R1, R2, …, Rm}, the set consisting of all resource types in the system.
Process
Pi requests instance of Rj
Pi
Rj
Pi is holding an instance of Rj
Pi
Rj
Example of a Resource Allocation Graph
No Deadlock
Deadlock