Académique Documents
Professionnel Documents
Culture Documents
CHAPTER 3
PROCESS MANAGEMENT
New Terminat
Admitted Exit
Interrupt
Ready Runnin
g
Dispatch
I/O complete I/O
Waiting
Point Process
er state
Process number
Program counter
CPU registers
Memory
management
I/O information
13
.
.
frequently so that users interact with the system while their programs
are executing. In a uniprocessor system, there is always a single
process running while the other processes need to wait till they get the
CPU for execution on being scheduled.
As a process enters the system, it joins a job queue that is a list
of all processes in the system. Some of these processes are in the
ready state and are waiting for the CPU for execution. These processes
are present in a ready queue. The ready queue is nothing but a list of
PCB’s implemented as a linked list with each PCB pointing to the next.
There are also some processes that are waiting for some I/O
operation like reading from a file on the disk or writing on to a printer.
Such processes are present in device queues. Each device has its own
queue.
A new process first joins the ready queue. When it gets
scheduled, the CPU executes the process until
1. an I/O occurs and the process gives up the CPU to join a
device queue only to rejoin the ready queue after being
serviced for the I/O.
2. it gives up the CPU on expiry of its time slice and rejoins
the ready queue.
Every process is in this cycle until it terminates (Figure 3.3). Once
a process terminates, entries for this process in all the queues are
deleted. The PCB and resources allocated to it are released.
Ready CP
queue U
I/ I/O
I/O
Time slice 15
3.5 SCHEDULERS
Reload status
Executing
Interrupt
Save status into
:
Reload status from
Executing
18
3.7.1 MULTITASKING
Let round robin scheduling with a time slice of ‘n’ units be used. When
the above process is scheduled, ‘n’ units of CPU time will be allocated
to the process. But due to the Read, a system call is generated thereby
utilizing only a fraction of its time slice. When the process is ready after
the I/O and gets its next time slice, it again almost immediately goes
for an I/O because of the Write. This cycle continues till all the records
on the tape have been read, processed and written on to the disk. This
being an I/O bound process it spends more time executing I/O.
Multitasking provides a solution for the problem described
above. The entire process of reading, processing and writing is divided
into two tasks. The advantage here is that the two tasks can be run
concurrently when synchronized. The executable code for the two
tasks is maintained separately as shown below:
Begin
While not end-of-file
Begin
Task-0-begin
Read a record
Process the record
Task-0-end
Task-1-begin
Write a record
Task-1-end
End
End
A process in execution has a process control block (PCB)
associated with it which is created by the operating system. Similarly
each task created needs a task control block (TCB). The TCB saves
register information at the time of switching between tasks within a
process.
20
3.7.2 MULTITHREADING
21
3.8 SUMMARY
3.9 EXERCISE
3.10 ACTIVITY