SlideShare a Scribd company logo
1 of 29
© Oxford University Press 2014. All rights reserved.
Principles of Operating
Systems
Naresh Chauhan
© Oxford University Press 2014. All rights reserved.
Chapter 5
Fundamentals of Process
Management
© Oxford University Press 2014. All rights reserved.
Objectives
• Difference between job, program, task and process
• Process environment
• Life cycle of a process with its states and state transitions
• Implementation of Processes with process control block
• Context switching
• Process switching
• Process schedulers
• Various operations on processes
© Oxford University Press 2014. All rights reserved.
Program and Job
Program and Job used in batch systems.
Program is classical term used for user’s computation. A program is a
piece of code which may be a single line or millions of lines.
a job is the unit of work that a computer operator (or a program
called a job scheduler) gives to the operating system. For example, a
job could be the running of an application program such as a weekly
payroll program.
A job is usually said to be run in batch (rather than interactive) mode.
© Oxford University Press 2014. All rights reserved.
Job as a sequence of programs/work
© Oxford University Press 2014. All rights reserved.
Program/Process
• program in execution is called a process
• we write our computer programs in a text file and when we
execute this program, it becomes a process which performs all
the tasks mentioned in the program.
• a process is able to compete for resources
• program is a passive entity
• ‘task’ was used when there was need to have concurrent
execution on a single processor, i.e. more than one programs of
a single user.
© Oxford University Press 2014. All rights reserved.
Process environment
• When a program is loaded into the memory and it becomes a
process, it can be divided into four sections ─ stack, heap,
text/code and data.
• The following image shows a simplified layout of a process
inside main memory −
Heap
© Oxford University Press 2014. All rights reserved.
Program/Process
S.
N.
Component & Description
1 Stack
The process Stack contains the temporary data such as method/function
parameters, return address and local variables.
2 Heap
This is dynamically allocated memory to a process during its run time.
3 Text/Code Section
This includes the current activity represented by the value of Program
Counter and the contents of the processor's registers.
4 Data
This section contains the global and static variables.
© Oxford University Press 2014. All rights reserved.
Difference between program and
process
Program Process
Passive/Static Active/Dynamic
Cannot compete for resources Competes for resources
Has a code section Has a code section, data section,
stack, program counter
© Oxford University Press 2014. All rights reserved.
Life cycle of a process
© Oxford University Press 2014. All rights reserved.
Process states and state transitions
© Oxford University Press 2014. All rights reserved.
Process States
New
This is the state when the process has just been created. It is the initial state in
the process life cycle.
Ready
In the ready state, the process is waiting to be assigned the processor by the
short term scheduler, so it can run. This state is immediately after the new state
for the process.
Ready Suspended
The processes in ready suspended state are in secondary memory. They were
initially in the ready state in main memory but lack of memory forced them to
be suspended and gets placed in the secondary memory.
Running
The process is said to be in running state when the process instructions are
being executed by the processor. This is done once the process is assigned to
the processor using the short-term scheduler.
© Oxford University Press 2014. All rights reserved.
Process state diagram with
suspended states
© Oxford University Press 2014. All rights reserved.
Process States
Blocked
The process is in blocked state if it is waiting for some event to occur. This event
may be I/O as the I/O events are executed in the main memory and don't
require the processor. After the event is complete, the process again goes to
ready state.
Blocked Suspended
This is similar to ready suspended. The processes in blocked suspended state
are in secondary memory. They were initially in the blocked state in main
memory waiting for some event but lack of memory forced them to be
suspended and gets placed in the secondary memory. A process may go from
blocked suspended to ready suspended if its work is done.
Terminated
The process is terminated once it finishes its execution. In the terminated state,
the process is removed from main memory and its process control block is also
deleted.
© Oxford University Press 2014. All rights reserved.
Event types
Event Current State New State OS Actions
A new process is
created.
-- NEW Assigns an ID to the
process and some other
related information.
Process makes a
resource or I/O
request.
RUNNING BLOCKED Schedules the next
process from ready queue
and dispatches it to the
processor.
Resource or I/O is
released.
BLOCKED READY (If the resource
or I/O released is what
the BLOCKED process
requires)
Schedules the next
process from ready queue
and dispatches it to the
processor.
© Oxford University Press 2014. All rights reserved.
Event types
Event Current State New State OS Actions
An interrupt is
generated by
another process or
due to any other
reason.
RUNNING READY Schedules the next
process (interrupting
process if the interrupt
has come from this
process) from ready
queue and dispatches it to
the processor.
Process reaches to
its end of execution
or aborted.
RUNNING TERMINATED Schedules the next
process from ready queue
and dispatches it to the
processor.
© Oxford University Press 2014. All rights reserved.
Process control block
A Process Control Block is a data structure maintained by the Operating
System for every process.
The PCB is identified by an integer process ID (PID).
The following are the fields associated with a PCB:
• PID
• PC
• Registers
• State
• Priority
• Event information
• Pointer to parent process
• Pointer to child process
• Memory related information
• Scheduling related information
• Pointer to address space of the
process
© Oxford University Press 2014. All rights reserved.
Process control block
.N. Information & Description
1 Process State
The current state of the process i.e., whether it is ready, running, waiting, or
whatever.
2 Process privileges
This is required to allow/disallow access to system resources.
3 Process ID
Unique identification for each of the process in the operating system.
4 Pointer
A pointer to parent process.
5 Program Counter
Program Counter is a pointer to the address of the next instruction to be
executed for this process.
© Oxford University Press 2014. All rights reserved.
Process control block
.N. Information & Description
6 CPU registers
Various CPU registers where process need to be stored for execution for running
state.
7 CPU Scheduling Information
Process priority and other scheduling information which is required to schedule
the process.
8 Memory management information
This includes the information of page table, memory limits, Segment table
depending on memory used by the operating system.
9 Accounting information
This includes the amount of CPU used for process execution, time limits,
execution ID etc.
10 IO status information
This includes a list of I/O devices allocated to the process.
© Oxford University Press 2014. All rights reserved.
Process image
© Oxford University Press 2014. All rights reserved.
Implementation of processes
© Oxford University Press 2014. All rights reserved.
Queues
The various queues used here are implemented as linked lists.
There are mainly following queues:
Ready Queue for storing the processes with state ready.
Blocked queue for storing the processes which needs to wait
for some I/O or resource.
Suspended queue for storing the blocked processes which
have been suspended.
Free process queue for the information of empty space in
memory where a new PCB can be created.
© Oxford University Press 2014. All rights reserved.
PCB queues in memory
© Oxford University Press 2014. All rights reserved.
Sequence of activities during process
switching
© Oxford University Press 2014. All rights reserved.
Schedulers
Long-term scheduler
Short-term scheduler
Medium-term scheduler
© Oxford University Press 2014. All rights reserved.
Long-term, medium-term and short-term
scheduler
© Oxford University Press 2014. All rights reserved.
Process operations
Creation
The process identification (process ID) and its priority are assigned.
The memory and other resources required by the process are
allocated to it.
The code is copied in the code area, thereby setting the process
environment.
The operating system looks for a free PCB space in the free-process
queue for the newly created process and initializes all its fields.
An existing process may also create another process. This is known
as process spawning.
© Oxford University Press 2014. All rights reserved.
Process Hierarchy
© Oxford University Press 2014. All rights reserved.
Termination
When a process terminates, the memory occupied, open files,
and other resources are taken away from it.
Another reason for the termination of a process may be some
error or exception generated in the execution of the process. It
may be the case that process may
require more memory than allowed.
reference a memory location out of its limits.
Try to access a resource or I/O that is not allowed to use.
attempt an arithmetic operation that is not allowed, e.g. divide by
zero.
find an error while accessing an I/O.
child process termination

More Related Content

Similar to Process Basics.ppt

Process Management Operating Systems .pptx
Process Management        Operating Systems .pptxProcess Management        Operating Systems .pptx
Process Management Operating Systems .pptxSAIKRISHNADURVASULA2
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxAmanuelmergia
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxAmanuelmergia
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdfAmanuelmergia
 
Process management os concept
Process management os conceptProcess management os concept
Process management os conceptpriyadeosarkar91
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringYogesh Santhan
 
Unit 2 part 1(Process)
Unit 2 part 1(Process)Unit 2 part 1(Process)
Unit 2 part 1(Process)WajeehaBaig
 
Operating System
Operating SystemOperating System
Operating SystemGowriLatha1
 
Operating system
Operating systemOperating system
Operating systemMark Muhama
 
OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)Muhammad Osama
 
Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...ApurvaLaddha
 
Schudling os presentaion
Schudling os presentaionSchudling os presentaion
Schudling os presentaioninayat khan
 

Similar to Process Basics.ppt (20)

Process Management Operating Systems .pptx
Process Management        Operating Systems .pptxProcess Management        Operating Systems .pptx
Process Management Operating Systems .pptx
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptx
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptx
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
UNIT I-Processes.pptx
UNIT I-Processes.pptxUNIT I-Processes.pptx
UNIT I-Processes.pptx
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdf
 
Processing management
Processing managementProcessing management
Processing management
 
Process
ProcessProcess
Process
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - Engineering
 
Unit 2 part 1(Process)
Unit 2 part 1(Process)Unit 2 part 1(Process)
Unit 2 part 1(Process)
 
Operating System
Operating SystemOperating System
Operating System
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 
UNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdfUNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdf
 
Process Management
Process ManagementProcess Management
Process Management
 
Operating system
Operating systemOperating system
Operating system
 
OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)
 
Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...Process management- This ppt contains all required information regarding oper...
Process management- This ppt contains all required information regarding oper...
 
Lecture 2 process
Lecture 2   processLecture 2   process
Lecture 2 process
 
Schudling os presentaion
Schudling os presentaionSchudling os presentaion
Schudling os presentaion
 

Recently uploaded

Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesRAJNEESHKUMAR341697
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...Amil baba
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 

Recently uploaded (20)

Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 

Process Basics.ppt

  • 1. © Oxford University Press 2014. All rights reserved. Principles of Operating Systems Naresh Chauhan
  • 2. © Oxford University Press 2014. All rights reserved. Chapter 5 Fundamentals of Process Management
  • 3. © Oxford University Press 2014. All rights reserved. Objectives • Difference between job, program, task and process • Process environment • Life cycle of a process with its states and state transitions • Implementation of Processes with process control block • Context switching • Process switching • Process schedulers • Various operations on processes
  • 4. © Oxford University Press 2014. All rights reserved. Program and Job Program and Job used in batch systems. Program is classical term used for user’s computation. A program is a piece of code which may be a single line or millions of lines. a job is the unit of work that a computer operator (or a program called a job scheduler) gives to the operating system. For example, a job could be the running of an application program such as a weekly payroll program. A job is usually said to be run in batch (rather than interactive) mode.
  • 5. © Oxford University Press 2014. All rights reserved. Job as a sequence of programs/work
  • 6. © Oxford University Press 2014. All rights reserved. Program/Process • program in execution is called a process • we write our computer programs in a text file and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. • a process is able to compete for resources • program is a passive entity • ‘task’ was used when there was need to have concurrent execution on a single processor, i.e. more than one programs of a single user.
  • 7. © Oxford University Press 2014. All rights reserved. Process environment • When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text/code and data. • The following image shows a simplified layout of a process inside main memory − Heap
  • 8. © Oxford University Press 2014. All rights reserved. Program/Process S. N. Component & Description 1 Stack The process Stack contains the temporary data such as method/function parameters, return address and local variables. 2 Heap This is dynamically allocated memory to a process during its run time. 3 Text/Code Section This includes the current activity represented by the value of Program Counter and the contents of the processor's registers. 4 Data This section contains the global and static variables.
  • 9. © Oxford University Press 2014. All rights reserved. Difference between program and process Program Process Passive/Static Active/Dynamic Cannot compete for resources Competes for resources Has a code section Has a code section, data section, stack, program counter
  • 10. © Oxford University Press 2014. All rights reserved. Life cycle of a process
  • 11. © Oxford University Press 2014. All rights reserved. Process states and state transitions
  • 12. © Oxford University Press 2014. All rights reserved. Process States New This is the state when the process has just been created. It is the initial state in the process life cycle. Ready In the ready state, the process is waiting to be assigned the processor by the short term scheduler, so it can run. This state is immediately after the new state for the process. Ready Suspended The processes in ready suspended state are in secondary memory. They were initially in the ready state in main memory but lack of memory forced them to be suspended and gets placed in the secondary memory. Running The process is said to be in running state when the process instructions are being executed by the processor. This is done once the process is assigned to the processor using the short-term scheduler.
  • 13. © Oxford University Press 2014. All rights reserved. Process state diagram with suspended states
  • 14. © Oxford University Press 2014. All rights reserved. Process States Blocked The process is in blocked state if it is waiting for some event to occur. This event may be I/O as the I/O events are executed in the main memory and don't require the processor. After the event is complete, the process again goes to ready state. Blocked Suspended This is similar to ready suspended. The processes in blocked suspended state are in secondary memory. They were initially in the blocked state in main memory waiting for some event but lack of memory forced them to be suspended and gets placed in the secondary memory. A process may go from blocked suspended to ready suspended if its work is done. Terminated The process is terminated once it finishes its execution. In the terminated state, the process is removed from main memory and its process control block is also deleted.
  • 15. © Oxford University Press 2014. All rights reserved. Event types Event Current State New State OS Actions A new process is created. -- NEW Assigns an ID to the process and some other related information. Process makes a resource or I/O request. RUNNING BLOCKED Schedules the next process from ready queue and dispatches it to the processor. Resource or I/O is released. BLOCKED READY (If the resource or I/O released is what the BLOCKED process requires) Schedules the next process from ready queue and dispatches it to the processor.
  • 16. © Oxford University Press 2014. All rights reserved. Event types Event Current State New State OS Actions An interrupt is generated by another process or due to any other reason. RUNNING READY Schedules the next process (interrupting process if the interrupt has come from this process) from ready queue and dispatches it to the processor. Process reaches to its end of execution or aborted. RUNNING TERMINATED Schedules the next process from ready queue and dispatches it to the processor.
  • 17. © Oxford University Press 2014. All rights reserved. Process control block A Process Control Block is a data structure maintained by the Operating System for every process. The PCB is identified by an integer process ID (PID). The following are the fields associated with a PCB: • PID • PC • Registers • State • Priority • Event information • Pointer to parent process • Pointer to child process • Memory related information • Scheduling related information • Pointer to address space of the process
  • 18. © Oxford University Press 2014. All rights reserved. Process control block .N. Information & Description 1 Process State The current state of the process i.e., whether it is ready, running, waiting, or whatever. 2 Process privileges This is required to allow/disallow access to system resources. 3 Process ID Unique identification for each of the process in the operating system. 4 Pointer A pointer to parent process. 5 Program Counter Program Counter is a pointer to the address of the next instruction to be executed for this process.
  • 19. © Oxford University Press 2014. All rights reserved. Process control block .N. Information & Description 6 CPU registers Various CPU registers where process need to be stored for execution for running state. 7 CPU Scheduling Information Process priority and other scheduling information which is required to schedule the process. 8 Memory management information This includes the information of page table, memory limits, Segment table depending on memory used by the operating system. 9 Accounting information This includes the amount of CPU used for process execution, time limits, execution ID etc. 10 IO status information This includes a list of I/O devices allocated to the process.
  • 20. © Oxford University Press 2014. All rights reserved. Process image
  • 21. © Oxford University Press 2014. All rights reserved. Implementation of processes
  • 22. © Oxford University Press 2014. All rights reserved. Queues The various queues used here are implemented as linked lists. There are mainly following queues: Ready Queue for storing the processes with state ready. Blocked queue for storing the processes which needs to wait for some I/O or resource. Suspended queue for storing the blocked processes which have been suspended. Free process queue for the information of empty space in memory where a new PCB can be created.
  • 23. © Oxford University Press 2014. All rights reserved. PCB queues in memory
  • 24. © Oxford University Press 2014. All rights reserved. Sequence of activities during process switching
  • 25. © Oxford University Press 2014. All rights reserved. Schedulers Long-term scheduler Short-term scheduler Medium-term scheduler
  • 26. © Oxford University Press 2014. All rights reserved. Long-term, medium-term and short-term scheduler
  • 27. © Oxford University Press 2014. All rights reserved. Process operations Creation The process identification (process ID) and its priority are assigned. The memory and other resources required by the process are allocated to it. The code is copied in the code area, thereby setting the process environment. The operating system looks for a free PCB space in the free-process queue for the newly created process and initializes all its fields. An existing process may also create another process. This is known as process spawning.
  • 28. © Oxford University Press 2014. All rights reserved. Process Hierarchy
  • 29. © Oxford University Press 2014. All rights reserved. Termination When a process terminates, the memory occupied, open files, and other resources are taken away from it. Another reason for the termination of a process may be some error or exception generated in the execution of the process. It may be the case that process may require more memory than allowed. reference a memory location out of its limits. Try to access a resource or I/O that is not allowed to use. attempt an arithmetic operation that is not allowed, e.g. divide by zero. find an error while accessing an I/O. child process termination