You are on page 1of 35

PROCESS DESCRIPTION

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 1


OS is an entity which manages the use of system resources by processes.

• The OS controls events within the computer system.

• It schedules and dispatches processes for execution by the processor, allocates resources to
processes, and responds to requests by user programs for basic services.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 2


PROCESSES AND RESOURCES

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 3


OS Control structures

• To manage processes and resources the OS must have current status of each process and resource.
• The OS constructs and maintains a tables of information about each entity that it is managing.

Fig. General structure of OS control tables


8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 4
Memory tables are used to keep track of both main (real) and secondary (virtual) memory

Processes are maintained on secondary memory using some sort of virtual memory or simple
swapping mechanism.

The memory table information includes:


1. The allocation of main memory to processes

2. The allocation of secondary memory to processes

3. Any protection attributes or blocks of main or virtual memory, such as which processes may
access certain shared memory regions.

4. Any information needed to manage virtual memory.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 5


I/O Tables are used by the OS to manage the I/O devices and channels of the
computer system.

If I/O operation is in progress, the OS needs to know the status of the I/O
operation and location in main memory being used as the source or destination
of the I/O transfer.

File tables provide information about the existence of files, their location on
secondary memory, their current status and other attributes.

Process tables to manage processes

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 6


Process control structure

• A process will consist of at least sufficient memory to hold the programs and data of that process.

• The execution of a program typically involves a stack that is used to keep track of procedure calls and parameter
passing between procedures.

• Each process is associated with a number of attributes that are used by OS for process control- referred as process
control block.

• Collection of program, data, stack and attributes - process image

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 7


Typical elements of process control block

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 8


…….

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 9


User processes in virtual memory

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 10


Process list structures

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 11


The Role of the Process Control Block

• It is a most important data structure in OS

• It contains all the information about a process that is needed by the OS

• The blocks are read and /or modified by virtually every module in the OS, including those
involved with scheduling , resource allocation, interrupt processing., and performance
processing and analysis.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 12


PROCESS CONTROL
Less privileged mode- user mode

More privileged mode- system mode, control mode or kernel mode

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 13


Typical functions of an operating system kernel

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 14


PROCESS CREATION

• Assign a unique process identifier to the new process: a new entry is added to the primary process
table, which contains one entry per process

• Allocate space for the process: includes all elements of the process image

• Initialize the PCB: process identification and control information

• Set the appropriate linkages: ex. If OS maintains each scheduling queue as a linked list, then the new process
must be put in the ready or ready/suspend list

• Create or expand other data structures: accounting information

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 15


Process switching
A process switch may occur any time that the OS has gained control from the currently running
process

Mechanism for interrupting the execution of a process

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 16


Clock interrupt: The OS determines whether the currently running process has been executing for
the maximum allowable time slice. If so, this process must be switched to Ready state and another
process is dispatched.

I/O interrupt : The OS determines what action has occurred. If the I/O action constitutes an event
for which one or more processes are waiting, then OS moves all of the corresponding blocked processes
to the ready state (and Blocked /suspend processes to Ready/suspend state).
The OS then decides whether to resume execution of the process currently running or to
preempt that process for a higher priority Ready process.

Memory Fault: The process tries to access a virtual memory address for a word that is not in the main
memory.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 17


Change of a process state

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 18


Process based OS

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 19


a) When a currently running process is interrupted or issues a supervisor call , the mode context of
this process is saved and control is passed to the kernel.--- concept of process is considered to apply
only to user programs. The OS code is executed as a separate entity that operates in privileged
mode.

b) At any given point , the OS is managing n process images. A separate kernel stack is used to
manage calls/ returns while the process in kernel mode. OS code and data are in shared address
space and are shared by all user processes.
If any mode switch occurs within the same process this method is advantageous.

c) Major kernel functions are organized as separate process. There may be small amount of process
switching code that is executed outside of any process.
Advantages: i) imposes a program design using modular O with minimal , clean interfaces between
modules
ii) some non critical OS functions are conventionally implemented as separate
processes
8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 20
PROCESS CHARACTERISTICS

Resource ownership: A process includes a virtual address space to hold the process image , and
from time to time may be allocated control or ownership of resources such as main memory, I/O
channels, I/O devices and files.

The OS performs a protection function to prevent unwanted interferences between processes with
respect to resources.

Scheduling/execution: The execution of a process follows an execution path (trace) through one
or more programs.

This execution may be interleaved with that of other processes. Thus, a process has an execution state (
Running, ready , etc) and a dispatching priority and is the entity that is scheduled and dispatched by the
OS.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 21


• The resource ownership and scheduling / execution are the characteristics of the process.

• Theses two characteristics could be treated independently by the OS.

• To distinguish the two characteristics, the unit of dispatching is usually referred to as a THREAD or
Light weight process.

• The unit of resource ownership is usually referred to as a PROCESS, or TASK.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 22


Multithreading

In a multithreaded environment, a process is defined as the unit of resource


allocation and a unit of protection.

The process is associated with :

• A virtual address space that holds the process image

• Protected access to processors, other processes (for inter process


communication), files and I/O resources (devices and channels)

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 23


Threads and Processes

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 24


8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 25
Single threaded and multithreaded process models

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 26


8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 27
Thread Functionality

• The key states for a thread are Running, Ready and Blocked.

• When process is suspended, the thread also get suspended

There are 4 basic operations associated with a change in thread state:

• Spawn
• Block
• Unblock
• Finish

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 28


RPC Using Threads

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 29


Remote Procedure Call (RPC) is a powerful technique for constructing distributed, client-
server based applications. It is based on extending the conventional local procedure calling so that
the called procedure need not exist in the same address space as the calling procedure.
The two processes may be on the same system, or they may be on different systems with a network
connecting them.
When making a Remote Procedure Call:

1. The calling environment is suspended, procedure parameters are transferred across the
network to the environment where the procedure is to execute, and the procedure is executed
there.

2. When the procedure finishes and produces its results, its results are transferred back to the
calling environment, where execution resumes as if returning from a regular procedure call.

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 30


RPC is especially well suited for client-server (e.g. query-response) interaction in which the flow
of control alternates between the caller and callee. Conceptually, the client and server do not
both execute at the same time. Instead, the thread of execution jumps from the caller to the callee and
then back again.
8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 31
Multithreading example on a Uniprocessor

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 32


User level and kernel level threads

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 33


8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 34
Reference :

William Stallings , Operating systems, PHI

8/26/2022 Dr.Kanthi.M, Professor, ECE Dept., M.I.T ,Manipal 35

You might also like