Operating Systems Processes
Operating Systems Processes
PROCESSES
3: Processes 1
OPERATING SYSTEM
Processes
What Is In This Chapter?
Process Definition
Scheduling Processes
What Do Processes Do?
Inter-process Communication
3: Processes 2
Definitions
PROCESSES
PROCESS CONCEPT:
3: Processes 3
PROCESSES PROCESS STATE
New The process is just being put together.
Running Instructions being executed. This running process holds the CPU.
Ready The process has all needed resources - waiting for CPU only.
Suspended Another process has explicitly told this process to sleep. It will be
awakened when a process explicitly awakens it.
3: Processes 4
PROCESSES Process State
3: Processes 5
Scheduling
PROCESSES Components
The act of Scheduling a process means changing the active PCB pointed to by the CPU.
Also called a context switch.
A context switch is essentially the same as a process switch - it means that the memory,
as seen by one process is changed to the memory seen by another process.
See Figure on Next Page (4.3)
SCHEDULING QUEUES:
What do the queues look like? They can be implemented as single or double linked.
See Figure Several Pages from Now (4.4)
3: Processes 6
Scheduling
PROCESSES Components
3: Processes 7
Scheduling
PROCESSES Components
Ready Q
And
IO Qs
Figure 4.4
3: Processes 8
Scheduling
PROCESSES Components
Code to remove a process from the processor at the end of its run.
a)Process may go to ready queue or to a wait state.
3: Processes 9
Scheduling
PROCESSES Components
Code to take a process off the ready queue and run that process (also called
dispatcher).
a) Always takes the first process on the queue (no intelligence required)
b) Places the process on the processor.
3: Processes 10
Scheduling
PROCESSES Components
INTERRUPT HANDLER
In addition to doing device work, it also readies processes, moving them, for
instance, from waiting to ready.
Short Term
Scheduler
Fig 4.5
3: Processes 11
Scheduling Processes
PROCESSES and Threads
3: Processes 12
Process
PROCESSES Relationships
Parent can run concurrently with child,
or wait for completion.
Independent Execution is
deterministic and reproducible.
Execution can be stopped/ started
without affecting other processes.
3: Processes 14
Interprocess
PROCESSES Communication
DIRECT COMMUNICATION:
Need to know name of sender/receiver. Mechanism looks like this:
send ( Process_P, message ) ;
receive ( Process_Q , message );
receive ( id, message ) <-- from any sender
repeat repeat
produce item receive( producer, nextp )
send( consumer, nextp) consume item
until false until false
3: Processes 15
Interprocess
PROCESSES Communication
The names of processes must be known - they can't be easily changed since they are
explicitly named in the send and receive.
3: Processes 16
Interprocess
PROCESSES Communication
INDIRECT COMMUNICATION
Processes communicate via a named mailbox rather than via a process name.
Mechanism looks like this:
open( mailbox_name );
send ( mailbox_name, message );
receive ( mailbox_name, message);
More than two processes are allowed to use the same mailbox.
May cause confusion with multiple receivers - if several processes have outstanding
receives on a mailbox, which one gets a message?
3: Processes 17
Interprocess
PROCESSES Communication
BUFFERING:
Options include:
Zero -- sender must wait for recipient to get message. Provides a rendezvous.
Bounded -- sender must wait for recipient if more than n messages in buffer.
MESSAGE FORMAT:
3: Processes 18
Interprocess
PROCESSES Communication
3: Processes 19
PROCESSES
WRAPUP
Seen how they get scheduled (and studied schedulers in doing so),
Visited the actions that can be performed on objects,
Examined the extension of processes called threads,
Looked at how processes communicate with each other
3: Processes 20