0% found this document useful (0 votes)
7 views

part2

The document discusses process description and control in operating systems, focusing on the structure and management of processes through Process Control Blocks (PCBs) and Thread Control Blocks (TCBs). It explains the various states of processes (new, ready, running, waiting, terminated) and the scheduling mechanisms that assign processes to the CPU to optimize performance. Additionally, it outlines the roles of different types of schedulers, such as long-term, short-term, and mid-term, in managing process queues.

Uploaded by

Said Bouargalne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

part2

The document discusses process description and control in operating systems, focusing on the structure and management of processes through Process Control Blocks (PCBs) and Thread Control Blocks (TCBs). It explains the various states of processes (new, ready, running, waiting, terminated) and the scheduling mechanisms that assign processes to the CPU to optimize performance. Additionally, it outlines the roles of different types of schedulers, such as long-term, short-term, and mid-term, in managing process queues.

Uploaded by

Said Bouargalne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Operating Systems

“Process description and control”

Mathieu Delalandre
University of Tours, Tours city, France
[email protected]

Lecture available at http://mathieu.delalandre.free.fr/teachings/operating1.html


Main
memory

*PCB-X
Process description and control (1) *PCB-B
*PCB-A
Queue 2

A process(us) is an instance of a computer program that is being executed. It

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

List of frequent data appearing in a PCB

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)

Multitasking (i.e. multiprogramming) is a method by which multiple CPU


tasks share common processing resources such as a CPU. With a single allocation
CPU, only one task can run at any time. Multitasking solves the problem
by scheduling the tasks i.e. which task must run on the CPU, and which
task must wait. P1

t
P2
t
P3

0 t
scheduling diagram of processes

The process Pi is running

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

In many systems, the scheduling activity is broken into three separate


functions: long, medium and short-term scheduling. 5. dispatcher 4. short-term
scheduler
Scheduling affects the performance of the system because it determines
which processes will wait and which will progress. Scheduling is a
matter of managing queues to minimize queuing delay and to optimize
… …
performance in a queuing environment.
2. long-term … …
scheduler 7. mid-term …
… 3. ready 6. blocked scheduler
queue queue
1. job 8. suspend
queue Main memory queue(s)

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.

2. Long term scheduler (admission scheduler) decides which CPU


processes are to be admitted to the ready queue, they are then created
and loaded into the main memory.
5. dispatcher 4. short-term
3. Ready queue is a data structure to keep in the main memory the scheduler
processes that are in a ready state.

4. Short-term scheduler (i.e. CPU scheduler) decides which of the


… …
ready, in-memory processes, are to be executed (allocated to the CPU)
2. long-term … …
following a clock interrupt, an I/O interrupt, an operating system call or scheduler 7. mid-term …
ayn other form of signal. … 3. ready 6. blocked scheduler
queue queue
1. job 8. suspend
5. Dispatcher gives the control of the CPU to the process selected by queue Main memory queue(s)
the short-term scheduler.

6
Process description and control (6)

6. Waiting/Blocked queue is a data structure to keep in the main


memory the processes in a blocked state.

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

Suspended Activate Running


Ready
ready
Suspend
I/O or event Scheduler
completion I/O or event dispatch I/O or event
completion wait
Suspended Suspend Waiting/
blocked Blocked
Activate

Disk memory Main memory


As a process executes, it changes its state. The state of a process is defined in part by the current activity of the process.

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).

Running: process is being executed by CPU.

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

Suspended Activate Running


Ready
ready
Suspend
I/O or event Scheduler
completion I/O or event dispatch I/O or event
completion wait
Suspended Suspend Waiting/
blocked Blocked
Activate

Disk memory Main memory


As a process executes, it changes its state. The state of a process is defined in part by the current activity of the process.

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.

Terminated  Ready: this transition has nosense.

12

You might also like