Finals of Kant get Marx 2.0 : a general politics quiz
OperatingSystem02..(B.SC Part 2)
1. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 1
Chapter 2: Processes
Process Concept
Process States
Process Control Block(PCB)
Process Scheduling
Operations on Processes
Cooperating Processes
Inter process Communication
2. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 2
Process Concept
An operating system executes a variety of programs:
Batch system – jobs
Time-shared systems – user programs or tasks
The terms job and process are almost interchangeable.
Process – a program in execution or manipulation
A process has the attributes(properties) of
program counter
Is used to keep track of the address
0f the next instruction to be executed.
Stack: Is used to store temporary data for the process.
3. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 3
Five State Process Model
As a process executes, it changes
state
new: The process is being
created.
ready: The process is waiting
to be assigned to a process.
running: Instructions are
being executed.
waiting: The process is
waiting for some event to
occur.
terminated: The process has
finished execution.
5. State Transition in Process
New to Ready: Admitted to Ready queue, can be considered by
CPU scheduler
Ready to Running: To be executed next for processing
Running to Ready: Process has used its current time slice
Running to Blocked: Process is waiting for some event to
occur.e.g I/O operation to complete.
Blocked to Ready: Whatever event the process was waiting has
occurred.
Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 5
6. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 6
Process Control Block (PCB)
It is a data structure that contains all
the information for a process to be
used for controlling its execution and
the resources used for that process.
Every process has its own PCB.
Information associated with each
process.
Process state (Ready, running, wait)
Program counter (Points to the next
instruction to be executed)
CPU registers(Data is stored in
registers after Interrupt occurs )
7. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 7
•CPU scheduling information: It holds the
information such as process priority.
•Memory-management information
(information such as base register, page
table etc)
•Accounting information: ( Holds the
amount of CPU time, process to date, or
process number)
•I/O status information: (Holds the list of
I/O devices)
8. Process Scheduling
Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 8
Technique used where there are limited resources and many
processes competing for them.
This is needed when there are more processes and one
processor.
In this way some processes will have to wait until CPU
becomes available. If there are more processes then the
operating system must schedule the process. Many
techniques are used for this purpose.
9. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 9
Process Scheduling Queues
Job queue – set of all processes in the system.
Ready queue – set of all processes residing in main
memory, ready and waiting to execute.
Device queues – set of processes waiting for an I/O
device.
10. Process migration between
various queues
The process of moving between various
queues is known as Process migration.
i.e moving between ready, waiting and
possibly job queues and finally job finishes the
task.
Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 10
11. CPU Scheduler
Selects from among the processes in memory
that are ready to execute, and allocates the
CPU to one of them.
Non-preemptive Scheduling
Once CPU has been allocated to a process, the
process keeps the CPU until
Process exits
Preemptive Scheduling
Process can be interrupted and must release the
CPU after time slice terminates.
12. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 12
Schedulers
Long-term scheduler (or job scheduler) –
selects which processes should be brought from
job queue into the ready queue. Processes are
added to the system much less frequently then
processes are swapped between the ready queue
and CPU.The long term scheduler controls the
degree of multiprogramming. Long term
scheduler should select a good process mix of
processes to better the system performance. It
is also called as job scheduling.
14. SHORT-TERM SCHEDULER:
(or CPU scheduler) – selects which process should
be executed next and allocates CPU. It selects a
process from ready queue and gives the control of
CPU to that process. Processes gets the CPU for a
short time slice while the short time scheduler
decides that which job well run next.
Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 14
15. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 15
Medium Term Scheduling
Time sharing OSs may introduce a medium term
scheduler
Removes processes from memory to reduce the degree
of multiprogramming
It swaps the process between memory and secondary
storage. It improves the system by reducing the degree
of multiprogramming.
I/O-bound process – spends more time doing I/O than
computations.
CPU-bound process – spends more time doing
computations.
16. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 16
Context Switch
When the CPU switches to another process, an
interrupt occurs.
The system must save the state of the old process
and load the saved state for the new process.
Context-switch time is overhead; the system does
no useful work while switching.
17. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 17
Process Creation
Parent process create children processes which, in turn,
create other processes forming a tree of processes.
Each process is assigned a unique process identifier (pid)
Resource sharing
Parent and children share all resources.
Children share subset of parent’s resources.
Execution
Parent and children execute concurrently.
Parent waits until some or all of its children terminate.
18. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 18
Process Termination
Process executes last statement and asks the
operating system to delete it by using the exit
Time Slot finished
Process’ resources are deal located by operating system.
Parent may terminate execution of children processes
Child has exceeded allocated resources.
Task assigned to child is no longer required.
Parent is exiting.
Some operating systems do not allow child to continue if its
parent terminates
19. Inter Process Communication
An IPC is used to provide two operations of sending
and receiving message. If two process wish two
communicate with each other.
Establish a communication link between them.
Exchange messages using the send and receive
operations.
To synchronize there actions
Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 19
20. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 20
Direct Communication
Processes must name each other explicitly (a
disadvantage):
send (P, message) – send a message to process P
receive(Q, message) – receive a message from process Q
Properties of communication link
Links are established automatically.
A link is associated with exactly one pair of communicating
processes.
Between each pair there exists exactly one link.
The link may be unidirectional, but is usually bi-directional.
the print server.
21. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 21
Indirect Communication
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.
22. Silberschatz / OS Concepts / 6e - Chapter 4 Processes Slide 22
Buffering(RAM)
Whether the communication link is direct or
indirect, messages exchanged by communicating
processes resides in a temporary queue.
e.g Copy, Paste
Bounded capacity
Unbounded capacity