Chapter 3 Process Concepts - Operating System Concepts
Chapter 3 Process Concepts - Operating System Concepts
When a process is created: OS allocates a PCB for it, initializes it, and puts its PCB on
the correct queue
As a process computes OS moves its PCB from queue to queue
When a process is terminated OS deallocates its PCB
Process migrates between various queues: OS must select processes from queues
according to some scheduling policy.
Process selection is done by schedulers.
Long-term scheduler (job scheduler) – selects processes to be loaded into memory
(into the ready queue).
Short-term scheduler (CPU scheduler) – selects a process (from the ready-queue) to
be executed on the CPU.
Short-term scheduler is invoked very frequently (milliseconds) (must be fast).
Long-term scheduler is invoked very infrequently (seconds, minutes) (may be slow).
It is important that the long-term scheduler selects a good process mix to ensure that the
system is balanced.
If all processes selected are IO-bound, the ready-queue will be empty and CPU
idles. If all processes selected are CPU-bound, IO device queues will be empty and
in both cases the system will be unbalanced.
Process executes last statement and then asks the operating system to delete it
using the exit() system call.
Returns status data from child to parent (via wait())
Process’ resources are deallocated by operating system
Parent may terminate the execution of children processes using the abort()
system call. Some reasons for doing so:
Child has exceeded allocated resources
Task assigned to child is no longer required
The parent is exiting and the operating systems does not allow a child to
continue if its parent terminates
Shared data
#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
while (true) {
while (in == out)
; /* do nothing */
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
Messages are directed and received from mailboxes (also referred to as ports)
Each mailbox has a unique id
Processes can communicate only if they share a mailbox
Properties of communication link
Link established only if processes share a common mailbox
A link may be associated with many processes
Each pair of processes may share several communication links
Link may be unidirectional or bi-directional
message next_produced;
while (true) {
/* produce an item in next_produced */
send(next_produced);
}
message next_consumed;
while (true) {
receive(next_consumed)