part2
part2
Mathieu Delalandre
University of Tours, Tours city, France
[email protected]
*PCB-X
Process description and control (1) *PCB-B
*PCB-A
Queue 2
Kernel space
*PCB-A
Refer to
contains the program code and the liked data. *PCB-X
*PCB-B
PCB “Process Control Block” (i.e. Task Controlling Block or Task Structure) is a Queue 1
data structure in the operating system kernel containing the information needed to
manage a particular process.
PCB-A
PCB-B
Processus Table is an area of memory protected from normal user access, to manage
the PCBs, as they contain critical information for processes.
Process table
A thread takes part of a process but it has its own program counter, stack and
Refer to
registers. The threads belonging to a process share common code and data.
Data
TCB “Thread Control Block” is a data structure in the operating system kernel Process A
Working space
containing the information needed to manage a particular thread (PCB look-like). Program
Data
Process B
Program
2
Main
memory
*PCB-X
Process description and control (2) *PCB-B
*PCB-A
Queue 2
Kernel space
*PCB-A
Refer to
*PCB-X
Process identifier (pid) refers the process in the OS. *PCB-B
Group data, hierarchy information (e.g. parents and childs), type of Queue 1
process and group memberships.
related to process
CPU-scheduling information e.g. process priority, pointers to
management
PCB-A
scheduling queues, etc. PCB-B
Process state e.g. ready, running, waiting, terminated, etc.
Program counter (PC) refers the current execution state of the process.
CPU registers correspond to the current state of the CPU.
Security attributes refer the owner or set of permissions (allowable Process table
operations) of the process.
Refer to
Accounting information e.g. start time, end time, amount of CPU used,
real-time used, etc. Data
Etc. Process A
Working space
Program
Memory management information includes page and segment tables
related to data
management
on the executable code, call stack (to keep track of active subroutines
Data
and/or other events), etc. Process B
Operating system descriptors refer to the resources that are allocated Program
to the process, such as files, devices, other data sources.
Etc.
3
Process description and control (3)
t
P2
t
P3
0 t
scheduling diagram of processes
4
Process description and control (4)
Scheduling refers to the way processes are assigned to run on the CPU.
The aim of scheduling is to assign processes to be executed by the
processor over the time, in a way that meets objectives of the system,
such as the response time, throughput and processor efficiency. CPU
5
Process description and control (5)
1. Job queue stores processes to enter in the system, they are put into
the job queue. The job queue contains the list of processes to create.
6
Process description and control (6)
7. Mid-term scheduler removes processes from the main memory (if CPU
full) and places them on a secondary memory (such as a disk drive) and
vice-versa.
5. dispatcher 4. short-term
8. Blocked suspend queue(s) contain lists of processes moved to the scheduler
disk (i.e. swapping). Two queues are usually managed, related to the
processes in a suspended-blocked or a suspended-ready state.
… …
2. long-term … …
scheduler 7. mid-term …
… 3. ready 6. blocked scheduler
queue queue
1. job 8. suspend
queue Main memory queue(s)
7
Long-term Short-term Long-term
Process description
New Terminated
and control (7) Mid-term Admitted Admitted Exit
Interrupt
New: in this state, the process awaits for an admission to the ready state. This admission will be approved or delayed
by a long-term, or admission, scheduler.
Ready: a ready process has been loaded into the main memory and the ready queue and is awaiting for an execution
on the CPU (to be loaded into the CPU by the dispatcher following the decision of the short-term scheduler).
Terminated: a process may be terminated, either from the running state by completing its execution or by explicitly
being killed. If a process is not removed from the memory, this state may also be called zombie.
8
Long-term Short-term Long-term
Process description
New Terminated
and control (8) Mid-term Admitted Admitted Exit
Interrupt
Waiting/Blocked: a process that cannot execute until some events occurs, such as the completion of an I/O operation
or a signal. Every blocked process is moved to the blocked queue.
Suspended blocked: a process is put in the disk memory by the mid-term scheduler (i.e. swapping out).
Suspended ready: a process is ready to be loaded from the disk to the main memory (i.e. swapping in).
9
Process description and control (9)
Queuing diagram for scheduling shows the queues involved in the state transitions of processes.
Rq. For simplicity, this diagram shows new processes going directly to the ready state without the option of either
the ready state or either the ready/suspend state.
long-term
short-term
scheduling
scheduling
CPU Exit
job queue ready queue
medium-term
mid-term
scheduling
scheduling
ready-suspend
mid-term I/O or
queue
scheduling event wait
I/O or event
completion blocked-suspend mid-term
queue scheduling
blocked queue
10
Process description and control (10)
New Ready: the OS will move a process from the new state to the ready state (i.e. from the job queue to the ready
queue) when it is prepared to take an additional process. Most of the systems set some limits based on the number of existing
processes in memory.
Ready Running: when it is time to select a process to run, the OS chooses one of the processes in the ready state. This is
the job of the scheduler.
Running Terminated: the currently running process is terminated by the OS if the process indicates that it has
completed, or if it aborts.
Running Ready: the most common reasons for this transition are
(1) in the case of a preemptive scheduling, the OS assigns different levels of priority to different processes;
thus a process A can preempt a process B and B will go to the ready state and shift to the ready queue.
(2) the running process has reached the maximum allowable time for an uninterrupted execution (all the
multiprogramming OS impose this type of time discipline).
(3) a process may voluntarily release the control of the processor (e.g. a background process that performs some
accounting or maintenance functions periodically).
11
Process description and control (11)
Running Blocked: a process is put in the blocked state (and moves to the blocked queue) if
(1) it requests something (i.e. a resource) for which it must wait such as a file, a shared section, etc. that is not
immediately available (e.g. a down operation on a Mutex).
(2) it requests a service to the OS that is not prepared to perform immediately. A request to the OS is usually in
the form of a system service call; that is; a call from the running program to a procedure that is part of the OS.
Blocked Running: a process in the blocked state is moved to the ready state (and moved to the ready queue) when the
event for which it has been waiting occurs (e.g. up operation on a Mutex, system call return, etc.).
Ready Terminated: this transition is not shown on the state and queuing diagrams, in some systems, a parent may
terminate a child process at any time. Also, if a parent terminates, all child processes associated wit that parent may terminate.
12