SlideShare a Scribd company logo
Processes
April 5, 2000
Instructor: Gary Kimura
Slides courtesy of Hank Levy
Process Management
 Process management deals with several issues:
 what are the units of execution
 how are those units of execution represented in the OS
 how is work scheduled in the CPU
 what are possible execution states, and how does the
system move from one to another
The Process
 Basic idea is the process:
 process is the unit of execution
 it’s the unit of scheduling
 it’s the dynamic (active) execution context (as opposed to a
program, which is static)
 A process is sometimes called a job or a task or a
sequential process.
 A sequential process is a program in execution; it
defines the sequential, instruction-at-a-time execution of
a program.
What’s in a Process?
 A process consists of at least:
 the code for the running program
 the data for the running program
 an execution stack tracing the state of procedure calls made
 the Program Counter, indicating the next instruction
 a set of general-purpose registers with current values
 a set of operating system resources (open files, connections
to other programs, etc.)
 The process contains all the state for a program in
execution.
Process State
 There may be several processes running the same
program (e.g., an editor), but each is a distinct process
with its own representation.
 Each process has an execution state that indicates what
it is currently doing, e.g.,:
 ready: waiting to be assigned to the CPU
 running: executing instructions on the CPU
 waiting: waiting for an event, e.g., I/O completion
 As a program executes, it moves from state to state
Process State Changing
New Ready Running
Terminated
Waiting
Processes move from state to state as a result of
actions they perform (e.g., system calls), OS actions
(rescheduling), and external actions (interrupts)
Process Data Structures
 At any time, there are many processes in the system,
each in its particular state.
 The OS must have data structures representing each
process: this data structure is called the PCB:
 Process Control Block
 The PCB contains all of the info about a process.
 The PCB is where the OS keeps all of a process’ hardware
execution state (PC, SP, registers) when the process is
not running.
PCB
The PCB contains lots of information, e.g.:
process state
process number
program counter
stack pointer
32 general-purpose registers
memory management info
username of owner
queue pointers for state queues
scheduling info (priority, etc.)
accounting info
PCBs and Hardware State
 When a process is running its Program Counter, stack
pointer, registers, etc., are loaded on the CPU (I.e., the
processor hardware registers contain the current values)
 When the OS stops running a process, it saves the
current values of those registers into the PCB for that
process.
 When the OS is ready to start executing a new process, it
loads the hardware registers from the values stored in
that process’ PCB.
 The process of switching the CPU from one process to
another is called a context switch. Timesharing systems
may do 100s or 1000s of context switches a second!
State Queues
 The OS maintains a collection of queues that represent
the state of all processes in the system.
 There is typically one queue for each state, e.g., ready,
waiting for I/O, etc.
 Each PCB is queued onto a state queue according to its
current state.
 As a process changes state, its PCB is unlinked from one
queue and linked onto another.
State Queues
Ready Queue Header
Wait Queue Header
head ptr
tail ptr
head ptr
tail ptr
PCB WPCB A PCB G
PCB X PCB M
There may be many wait queues, one for each
type of wait (specific device, timer, message,…).
PCBs and State Queues
 PCBs are data structures, dynamically allocated in OS
memory.
 When a process is created, a PCB is allocated to it,
initialized, and placed on the correct queue.
 As the process computes, its PCB moves from queue to
queue.
 When the process is terminated, its PCB is deallocated.
Creating a Process
 One process can create other processes to do its work.
These are child processes and the creator is the parent.
 In some systems, the parent defines (or donates)
resources and privileges for its children.
 When a child is created, the parent may either wait for it
to finish its task, or continue in parallel.
 In Unix, subprocesses are created by a call to Fork; the
child is identical to the parent, except for a return code
from Fork. The child often begins by executing a new
(and different) program within itself, via a call to Exec.
(Fork and Exec are Unix System Calls.)
Cooperating Processes
 Processes can be independent or they can be cooperating
to accomplish a single job.
 Cooperating processes can be used:
 to gain speedup by overlapping activities or performing
work in parallel
 to better structure an application as a small set of
cooperating processes
 to share information between jobs
 Sometimes processes are structured as a pipeline where
each produces work for the next stage that consumes it,
and so on.

More Related Content

What's hot

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
Dr. Loganathan R
 
Process management
Process managementProcess management
Process management
Mohd Arif
 
Memory Management
Memory ManagementMemory Management
Memory Management
Shipra Swati
 
Os
OsOs
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
Kathirvel Ayyaswamy
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
QUONTRASOLUTIONS
 
Lecture5
Lecture5Lecture5
Lecture5
Ali Shah
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
ManishaJha43
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
Shashank Shetty
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
Wayne Jones Jnr
 
Operating system 3
Operating system 3 Operating system 3
Operating system 3
Prof. Dr. K. Adisesha
 
Windows XP operating system
Windows XP operating systemWindows XP operating system
Windows XP operating system
Himanshu Choudhary
 
Memory management
Memory managementMemory management
Memory management
Vishal Singh
 
Structure of processes ppt
Structure of processes pptStructure of processes ppt
Structure of processes ppt
Yojana Nanaware
 
Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows Vista
Trinh Phuc Tho
 
Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
Kathirvel Ayyaswamy
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
Amin Omi
 

What's hot (19)

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Process management
Process managementProcess management
Process management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Os
OsOs
Os
 
Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 
Lecture5
Lecture5Lecture5
Lecture5
 
Memory management ppt
Memory management pptMemory management ppt
Memory management ppt
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
 
Operating system 3
Operating system 3 Operating system 3
Operating system 3
 
Windows XP operating system
Windows XP operating systemWindows XP operating system
Windows XP operating system
 
Memory management
Memory managementMemory management
Memory management
 
Structure of processes ppt
Structure of processes pptStructure of processes ppt
Structure of processes ppt
 
Processes and Threads in Windows Vista
Processes and Threads in Windows VistaProcesses and Threads in Windows Vista
Processes and Threads in Windows Vista
 
Cs8493 unit 4
Cs8493 unit 4Cs8493 unit 4
Cs8493 unit 4
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
 

Similar to 4 process

Operating System 3
Operating System 3Operating System 3
Operating System 3
tech2click
 
UNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdfUNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdf
aakritii765
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
Rakibul Rakib
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
HikaTariku
 
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
Yogesh Santhan
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
Mukesh Chinta
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
DiptoRoy21
 
Linux process management
Linux process managementLinux process management
Linux process management
Raghu nath
 
Ch03- PROCESSES.ppt
Ch03- PROCESSES.pptCh03- PROCESSES.ppt
Ch03- PROCESSES.ppt
MeghaSharma474761
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
Babasab Patil
 
UNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdfUNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdf
AyushSharma651966
 
Os
OsOs
3 process management
3 process management3 process management
3 process management
Dr. Loganathan R
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
Shipra Swati
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
KumarMit2
 
Operating system
Operating systemOperating system
Operating system
Mark Muhama
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
Mohammad Almuiet
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
Ziyauddin Shaik
 
operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.ppt
gezaegebre1
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
YogapriyaJ1
 

Similar to 4 process (20)

Operating System 3
Operating System 3Operating System 3
Operating System 3
 
UNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdfUNIT-2-Process-Management.pdf
UNIT-2-Process-Management.pdf
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 
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
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Linux process management
Linux process managementLinux process management
Linux process management
 
Ch03- PROCESSES.ppt
Ch03- PROCESSES.pptCh03- PROCESSES.ppt
Ch03- PROCESSES.ppt
 
My ppt @ bec doms on process management
My ppt @ bec doms on process managementMy ppt @ bec doms on process management
My ppt @ bec doms on process management
 
UNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdfUNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdf
 
Os
OsOs
Os
 
3 process management
3 process management3 process management
3 process management
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Operating system
Operating systemOperating system
Operating system
 
Ch2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.pptCh2_Processes_and_process_management_1.ppt
Ch2_Processes_and_process_management_1.ppt
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
operating system for computer engineering ch3.ppt
operating system for computer engineering ch3.pptoperating system for computer engineering ch3.ppt
operating system for computer engineering ch3.ppt
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 

Recently uploaded

Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 

Recently uploaded (20)

Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 

4 process

  • 1. Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy
  • 2. Process Management  Process management deals with several issues:  what are the units of execution  how are those units of execution represented in the OS  how is work scheduled in the CPU  what are possible execution states, and how does the system move from one to another
  • 3. The Process  Basic idea is the process:  process is the unit of execution  it’s the unit of scheduling  it’s the dynamic (active) execution context (as opposed to a program, which is static)  A process is sometimes called a job or a task or a sequential process.  A sequential process is a program in execution; it defines the sequential, instruction-at-a-time execution of a program.
  • 4. What’s in a Process?  A process consists of at least:  the code for the running program  the data for the running program  an execution stack tracing the state of procedure calls made  the Program Counter, indicating the next instruction  a set of general-purpose registers with current values  a set of operating system resources (open files, connections to other programs, etc.)  The process contains all the state for a program in execution.
  • 5. Process State  There may be several processes running the same program (e.g., an editor), but each is a distinct process with its own representation.  Each process has an execution state that indicates what it is currently doing, e.g.,:  ready: waiting to be assigned to the CPU  running: executing instructions on the CPU  waiting: waiting for an event, e.g., I/O completion  As a program executes, it moves from state to state
  • 6. Process State Changing New Ready Running Terminated Waiting Processes move from state to state as a result of actions they perform (e.g., system calls), OS actions (rescheduling), and external actions (interrupts)
  • 7. Process Data Structures  At any time, there are many processes in the system, each in its particular state.  The OS must have data structures representing each process: this data structure is called the PCB:  Process Control Block  The PCB contains all of the info about a process.  The PCB is where the OS keeps all of a process’ hardware execution state (PC, SP, registers) when the process is not running.
  • 8. PCB The PCB contains lots of information, e.g.: process state process number program counter stack pointer 32 general-purpose registers memory management info username of owner queue pointers for state queues scheduling info (priority, etc.) accounting info
  • 9. PCBs and Hardware State  When a process is running its Program Counter, stack pointer, registers, etc., are loaded on the CPU (I.e., the processor hardware registers contain the current values)  When the OS stops running a process, it saves the current values of those registers into the PCB for that process.  When the OS is ready to start executing a new process, it loads the hardware registers from the values stored in that process’ PCB.  The process of switching the CPU from one process to another is called a context switch. Timesharing systems may do 100s or 1000s of context switches a second!
  • 10. State Queues  The OS maintains a collection of queues that represent the state of all processes in the system.  There is typically one queue for each state, e.g., ready, waiting for I/O, etc.  Each PCB is queued onto a state queue according to its current state.  As a process changes state, its PCB is unlinked from one queue and linked onto another.
  • 11. State Queues Ready Queue Header Wait Queue Header head ptr tail ptr head ptr tail ptr PCB WPCB A PCB G PCB X PCB M There may be many wait queues, one for each type of wait (specific device, timer, message,…).
  • 12. PCBs and State Queues  PCBs are data structures, dynamically allocated in OS memory.  When a process is created, a PCB is allocated to it, initialized, and placed on the correct queue.  As the process computes, its PCB moves from queue to queue.  When the process is terminated, its PCB is deallocated.
  • 13. Creating a Process  One process can create other processes to do its work. These are child processes and the creator is the parent.  In some systems, the parent defines (or donates) resources and privileges for its children.  When a child is created, the parent may either wait for it to finish its task, or continue in parallel.  In Unix, subprocesses are created by a call to Fork; the child is identical to the parent, except for a return code from Fork. The child often begins by executing a new (and different) program within itself, via a call to Exec. (Fork and Exec are Unix System Calls.)
  • 14. Cooperating Processes  Processes can be independent or they can be cooperating to accomplish a single job.  Cooperating processes can be used:  to gain speedup by overlapping activities or performing work in parallel  to better structure an application as a small set of cooperating processes  to share information between jobs  Sometimes processes are structured as a pipeline where each produces work for the next stage that consumes it, and so on.