The document discusses processes and process management in operating systems. It defines a process as a program in execution, which forms the basis of all computation. It describes process features like scheduling, creation, termination and communication. It explains that each process is represented by a process control block containing information like state, registers, memory and I/O. Context switching is defined as the process of suspending one process and executing another by saving and restoring process contexts through the process control block.
1. PROCESS
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
M.V B Murali Krishna M
Assistant Professor
B.Tech,M.Tech ,(PhD)
Department of Computer Science &
Engineering
2. OBJECTIVES
• To introduce the notion of a process -- a program in
execution, which forms the basis of all computation
• To describe the various features of processes, including
scheduling, creation and termination, and communication
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
3. CONTENT
• Process Concept- (RL- 103 page no)
• Process Control block- (RL - 105 page no)
• Context switching.- (RL - 112 Page.no)
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
4. WHAT IS A PROCESS?
• A process is a program in execution which then forms the
basis of all computation.
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
5. PROCESS CONCEPT
Process memory is divided into four sections for efficient working :
1. The Text section is made up of the compiled program code, read in from non-
volatile storage when the program is launched.
2. The Data section is made up of the global and static variables, allocated and
initialized prior to executing the main.
3. The Heap is used for the dynamic memory allocation and is managed via calls to
new, delete, malloc, free, etc.
4. The Stack is used for local variables. Space on the stack is reserved for local
variables when they are declared.
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
6. CONT..
Program is passive entity, process is active
Program becomes process when executable file loaded into memory
Execution of program started via GUI mouse clicks,
command line entry of its name, etc
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
7. PROCESS IN MEMORY
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
8. PROCESS STATE
As a process executes, it changes state
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to occur
ready: The process is waiting to be assigned to a processor
terminated: The process has finished execution
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
9. DIAGRAM OF PROCESS STATE
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
10. PROCESS CONTROL BLOCK (PCB)
• Each process is represented in the operating system by a
process control block(PCB) –also called a task control
block.
• It contains many pieces of information associated with a
specific process, including these
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
11. PROCESS CONTROL BLOCK (PCB)
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
12. INFORMATION ASSOCIATED WITH EACH PROCESS
• Process state
• Program counter
• CPU registers
• CPU scheduling information
• Memory-management information
• Accounting information
• I/O status information
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
13. Process state : the state may be new, ready , running ,waiting , halted .
Program Counter : This contains the address of the next instruction that needs to be executed in the
process.
CPU registers : This specifies the registers that are used by the process. They may include accumulators,
index registers, stack pointers, general purpose registers etc.
CPU Scheduling Information:- The process priority, pointers to scheduling queues etc. is the CPU
scheduling information that is contained in the PCB. This may also include any other scheduling
parameters.
Memory Management Information:-The memory management information includes the page tables or the
segment tables depending on the memory system used. It also contains the value of the base registers,
limit registers etc.
I/O Status Information:- This information includes the list of I/O devices used by the process, the list of
files etc.
Accounting information:-The time limits, account numbers, amount of CPU used, process numbers etc. are
all a part of the PCB accounting information.
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
14. CONTEXT SWITCHING
What is context switching ?
A context switching is a process that involves switching of the CPU from one process or task
to another. In this phenomenon, the execution of the process that is present in the running state
is suspended by the kernel and another process that is present in the ready state is executed by
the CPU.
It is one of the essential features of the multitasking operating system. The processes are
switched so fastly that it gives an illusion to the user that all the processes are being executed
at the same time.
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
15. CPU SWITCH FROM PROCESS TO PROCESS
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E
16. THE FOLLOWING STEPS WILL BE PERFORMED:
1. Firstly, the context of the process P1 i.e. the process present in the running state will be
saved in the Process Control Block of process P1 i.e. PCB1.
2. Now, you have to move the PCB1 to the relevant queue i.e. ready queue, I/O queue,
waiting queue, etc.
3. From the ready state, select the new process that is to be executed i.e. the process P2.
4. Now, update the Process Control Block of process P2 i.e. PCB2 by setting the process
state to running. If the process P2 was earlier executed by the CPU, then you can get the
position of last executed instruction so that you can resume the execution of P2.
5. Similarly, if you want to execute the process P1 again, then you have to follow the same
steps as mentioned above(from step 1 to 4).
V A S A V I C O L L E G E O F E N G I N E E R I N G , D E P T . C S E