Process Concept
Process Concept
OPERATING SYSTEMS
Operating System Concepts – 9 th Edition 1.1 Silberschatz, Galvin and Gagne ©2013
Process Concept
An operating system executes a variety of programs:
Batch system – jobs
Time-shared systems – user programs or tasks
Textbook uses the terms job and process almost
interchangeably
Process – a program in execution; process execution must
progress in sequential fashion
A process includes:
program counter
stack
data section
Process in Memory
1 Stack
Stack contains the temporary data such as method/function parameters, return
address and local variables or procedure call information.
2 Heap
This is dynamically allocated memory to a process during its run time.
3 Data
This section contains the global and static variables. “program data” Statically
declared variables, Areas allocated by malloc() or new
4 Text
This includes the current activity represented by the value of Program Counter and
the contents of the processor's registers. “program code”
Process State
As a process executes, it changes state
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to occur
ready:The process is waiting to be assigned to a processor
terminated: The process has finished execution
Process Control Block (PCB)
A Process Control Block (PCB, also called Task Controlling Block or
Task Struct) is a data structure in the OS kernel containing the
information needed to manage a particular process.
The PCB is "the manifestation of a process in an operating system"
€ a := 1 € a := 1 € a := 1
b := a + 1 read a file b := a + 1
c := b + 1 b := a + 1 c := b + 1
read a file c := b + 1 a := b - c
a := b - c a := b - c c := c * b
c := c * b c := c * b b := 0
b := 0 b := 0 c := 0
How process state changes-2
€ a := 1 € a := 1 € a := 1
a
b := :=a 1+ 1 read a file b := a + 1
€ c :=b:=
a :=
b+
1a +
1 b := a1 +1 b := a + 1 c := b + 1
read ca:= fileb + c := b + 1 a := b - c
c€
:= b + 1
1aread
:=
readb - ac file a := b - c c := c * b
c := c:=*abbfile Timeout
c := c * b b := 0
a
:=0 b - c- c
b a:= b := 0 c := 0
c c:=:=c c* *b b
b b:=:=0 0
How process state changes-3
a := 1 € a := 1 € a := 1
b := a + 1 a
read :=a1file b := a + 1
c := b+1 € b :=read
a+a 1 fie
l c := b + 1
read a ffi
le cb:=:=ba++1 1 a := b - c
a := b - c ac:=:=bb-+ c1 c := c * b
c := c * b a :=
c := c *bb- c b := 0
b := 0 b c:=:=0 c * b c := 0
b := 0
I/O
How process state changes-4
a := 1 a := 1 € a := 1
b := a + 1 € read a fie
l a
b :=:=a1+ 1
€ c := ab:=:=+ 1a +
c := b + 1 b := a + 1
1 b := a 1
b +1
€ read a file c := b + 1 a := b c 1-:=cb+
a := b - c c := a := b - c c€:=
c :=b +
c*b
a 1:=
c * b b := Timeout
c := c * b := b0 b
ab :=
-c
0 b := 0 c c:= :=0 c * bc :=
- c
b c:=* 0b b :=
c := 00
c := 0
Representation of Process Scheduling
Scheduling refers to the way processes are assigned to
run on the available CPUs, since there are typically
many more processes running than there are available
CPUs.
This assignment is carried out by software known as a
scheduler or dispatcher.
Schedulers
Long-term scheduler (or job scheduler) – selects
which processes should be brought into the ready
queue
Short-term scheduler (or CPU scheduler) – selects
which process should be executed next and allocates
CPU