Processes: Process Concept Process Scheduling Operation On Processes Cooperating Processes Interprocess Communication
Processes: Process Concept Process Scheduling Operation On Processes Cooperating Processes Interprocess Communication
Processes: Process Concept Process Scheduling Operation On Processes Cooperating Processes Interprocess Communication
Process Concept
Process Scheduling
Operation on Processes
Cooperating Processes
Interprocess Communication
4.1
Process Concept
What to call all CPU activities ?
4.2
Process State
A program is passive entity, such as file containing a list of instructions stored
on disk, often called an executable file.
A program becomes a process when an executable file is loaded into memory .
4.3
4.4
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management information
Accounting information
I/O status information
4.5
4.6
4.7
Process Scheduling
The objective of multiprogramming is to have some running process at all times, to maximize CPU
utilization. The objective of time sharing is to switch the CPU among processes so frequently that the
users can interact with each program while it is running. To meet these objectives, the process
scheduler selects an available process(possibly from a set of several available processes) for program
execution on the CPU.
For a single processor system, there will never be more than one running process. If there are more
than processes, the rest will have to wait until the CPU is free and can be rescheduled.
4.8
4.9
4.10
4.11
Schedulers
In a batch system, more processes are submitted than can be executed
immediately. These processes are spooled to a mass storage device
(typically a disk), where they are kept for later execution.
Long-term scheduler (or job scheduler) selects which processes
should be brought into the ready queue (selects process from the
pool and load them in to memory)
Short-term scheduler (or CPU scheduler) selects which process
should be executed next and allocates CPU.
4.12
Schedulers (Cont.)
4.13
Schedulers (Cont.)
Stable degree of multiprogramming
If all the processes are I/O bound, the ready queue will almost always
be empty, and the short term scheduler will have little to do
If all processes are CPU-bound, the I/O waiting que will almost always
be empty, device will go unused, again the system will be unbalanced.
Make scheduler absent or minimal : Time sharing systems
such as UNIX or MS Windows often have no long term scheudler
but simply put every new process in memory for short term
scheduler.
Midium-term scheduler
4.14
4.15
Context Switch
4.16
Process Creation
Resource sharing
Parent and children share all resources.
Children share subset of parents resources.
Parent and child share no resources.
Execution
Parent and children execute concurrently.
Parent waits until children terminate.
4.17
Address space
The child process is a duplicate of the parent process (it has
the same program and data as the parent).
The child has a new program loaded into it.
4.18
Process Termination
4.19
Cooperating Processes
4.20
Producer-Consumer Problem
4.21
4.22
Direct Communication
4.23
Indirect Communication
Operations
create a new mailbox
send and receive messages through mailbox
destroy a mailbox
4.24
Mailbox sharing
P1, P2, and P3 share mailbox A.
P1, sends; P2 and P3 receive.
Who gets the message?
Solutions
Allow a link to be associated with at most two processes.
Allow only one process at a time to execute a receive
operation.
Allow the system to select arbitrarily the receiver. Sender is
notified who the receiver was.
4.25
Buffering
4.26
Process terminates
Lost messages
Scrambled Messages
4.27