Beruflich Dokumente
Kultur Dokumente
P20 P4
.
.
.
.
.
.
Process state Transitions
There are four state transitions two of them
caused by the process scheduler.
Process scheduler is a part of OS that decides
which process should get the CPU next.
1. Ready Running
– The assignment of the CPU to the first process on
the ready list is called dispatching and it is
performed by a system entity called dispatcher.
Dispatch (process_name):Ready Running
2. Running Ready
– A process may be stopped by a clock interrupt if
it doesn’t relinquish (release) the CPU before the
allocated time expires.
Timeout (process_name):Running Ready
3. Running waiting
– During I/O a process voluntarily relinquishes the
CPU.
Wait(process_name): Running waiting
4. Waiting Ready
– When I/O finishes
Wakeup(process_name): waiting Ready
Implementation of Processes
The OS maintains a table (an array of
structures), called the Process Table or
Process Control Block.
It enables an interrupted process to resume
normally.
It is an area of memory containing all the
relevant information associated with each
process.
These may include
– Process state
– Program counter
– Stack pointer
– Value of CPU registers when the process is
suspended.
– CPU scheduling information such as priority
– The area of memory used by the process(memory
management information)
– Accounting information: amount of CPU time
used, time limits, process no, etc.
– I/O status information: list of I/O devices such as
tape derives allocated for the process, a list of
open files, etc.
– Pointer to the next process’s PCB
Pointer Process
State
Process number
Program counter
Register
Memory limits
.
.
.
• The information is system dependent; e.g.,
there is an entry “parent process” in UNIX but
none in windows.
• All PCBs are linked to form a list, which is
accessed by a pointer in a central table.
• When a process changes state from ready to
running, its PCB is used by the OS to restart.
• The use of PCB will be shown later in Process
Scheduling.
2.2 Threads
A process has an address space (containing
program text and data) and a single thread of
control, as well as other resources such as
open files, child processes, accounting
information, etc.
The thread has a program counter, registers,
and a stack
Thread allows multiple executions to take
place in the same process environment, called
multithreading.
– (a) Three processes each with one thread. (b) One
process with three threads.
Each thread has a program counter, registers
stack, and state; but all threads of a process share
address space, global variables and other
resources such as open files, etc.
• The first column lists some items shared by all threads in a
process.
• The second one lists some items private to each thread.
• Threads are sometimes called light weight processes.
• Threads take turns in running
Thread Usage-Why do we need threads?