SlideShare a Scribd company logo
© 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

PPT
Ch03- PROCESSES.ppt
PDF
OS-Process.pdf
PPTX
Unit 2...............................................
PPTX
introduction to operating system unit 2
PDF
Operating System-Concepts of Process
PPTX
Os unit 3 , process management
PDF
OS - Process Concepts
PDF
unit-2.pdf
Ch03- PROCESSES.ppt
OS-Process.pdf
Unit 2...............................................
introduction to operating system unit 2
Operating System-Concepts of Process
Os unit 3 , process management
OS - Process Concepts
unit-2.pdf

Similar to Process Basics.ppt (20)

PPTX
Process Management in Operating System presentation.pptx
PPTX
Unit 1 process management operating system.pptx
PPTX
UNIT 2 OS.pptx Introduction of Operating System
PPT
OPERATING SYSTEM -UNIT 2.pptdeadlock detection – recovery from deadlock.
PDF
Operating system 2 by adi
PPTX
Operating System Process Scheduling.pptx
PPTX
Process Management Operating Systems .pptx
PPTX
Operating Systems chap 2_updated2.pptx
PPTX
Operating Systems chap 2_updated2 (1).pptx
PPTX
PROCESS.pptx
PPTX
UNIT I-Processes.pptx
PDF
Lecture 2- Processes.pdf
PPTX
Processing management
PDF
PPTX
Process management os concept
DOC
Operating Systems Unit Two - Fourth Semester - Engineering
PDF
process.pdfzljwiyrouyaeutoaetodtusiokklhh
PDF
Unit 2 part 1(Process)
PPTX
Operating System
PPTX
ch2nvbjdvsbjbjfjjfjf j Process Mangement.pptx
Process Management in Operating System presentation.pptx
Unit 1 process management operating system.pptx
UNIT 2 OS.pptx Introduction of Operating System
OPERATING SYSTEM -UNIT 2.pptdeadlock detection – recovery from deadlock.
Operating system 2 by adi
Operating System Process Scheduling.pptx
Process Management Operating Systems .pptx
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2 (1).pptx
PROCESS.pptx
UNIT I-Processes.pptx
Lecture 2- Processes.pdf
Processing management
Process management os concept
Operating Systems Unit Two - Fourth Semester - Engineering
process.pdfzljwiyrouyaeutoaetodtusiokklhh
Unit 2 part 1(Process)
Operating System
ch2nvbjdvsbjbjfjjfjf j Process Mangement.pptx
Ad

Recently uploaded (20)

PPTX
web development for engineering and engineering
PPT
Mechanical Engineering MATERIALS Selection
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PPT on Performance Review to get promotions
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Well-logging-methods_new................
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT
Project quality management in manufacturing
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
composite construction of structures.pdf
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
web development for engineering and engineering
Mechanical Engineering MATERIALS Selection
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT on Performance Review to get promotions
UNIT 4 Total Quality Management .pptx
Fundamentals of safety and accident prevention -final (1).pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Well-logging-methods_new................
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Project quality management in manufacturing
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
composite construction of structures.pdf
Current and future trends in Computer Vision.pptx
Internet of Things (IOT) - A guide to understanding
Foundation to blockchain - A guide to Blockchain Tech
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Ad

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