SlideShare uma empresa Scribd logo
1 de 26
Process
Objectives
• At the end of this topic, students should be able to:
• Define a Process
• Describe a Process State
• Describe the Process Operations
• Explain a Process Control Block (PCB)
Process
• a process is an instance of a computer program that is being executed.
• It contains the program code and its current activity.
• The execution of a process must progress in a sequential fashion.
• A process is defined as an entity which represents the basic unit of work to
be implemented in the system.
• To put it in simple terms, 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.
• When a program is loaded into the memory and it becomes a process, it
can be divided into four sections ─ stack, heap, text and data.
Process inside main memory
Program
• A program is a piece of code which may be a single line or
millions of lines.
• A computer program is usually written by a computer
programmer in a programming language.
• For example, here is a simple program written in C
programming language:
Processes vs. Programs
• A process is different than a program
• Program: Static code and static data
• Process: Dynamic instance of code and data
• No one-to-one mapping between programs and processes
• Can have multiple processes of the same program: Example:
many users can run “ls” at the same time
• One program can invoke multiple processes: Example: “make”
runs many processes to accomplish its work
Process Life Cycle/ Process State
• When a process executes, it passes through different states.
• These stages may differ in different operating systems, and the names
of these states are also not standardized.
• In general, a process can have one of the following five states at a
time.
Processes can be any of the following states :
• Start/New - The process is at the initial stage of being created.
• Ready - The process is waiting to be assigned to a processor. Ready processes
are waiting to have the processor allocated to them by the operating system so
that they can run. Process may come into this state after Start state or while
running it by but interrupted by the scheduler to assign CPU to some other
process.
• Running - The CPU is working on this process's instructions. Once the process
has been assigned to a processor by the OS scheduler, the process state is set
to running and the processor executes its instructions.
• Waiting - Process moves into the waiting state if it needs to wait for a resource,
such as waiting for user input, or waiting for a file to become available.
• Termination/ Exit - Once the process finishes its execution or it is terminated
by the operating system, it is moved to the terminated state where it waits to
be removed from main memory. The process has completed.
Diagram of process state
Process State Transitions
• Following are six(6) possible transitions among above mentioned five (5)
states
• Transition 1 occurs when process discovers that it cannot continue. If
running process initiates an I/O operation before its allotted time expires,
the running process voluntarily relinquishes the CPU. This state transition is:
Block (process-name): Running → Blocked
• Transition 2 occurs when the scheduler decides that the running process has
run long enough and it is time to let another process have CPU time. This
state transition is:
Time-Run-Out (process-name): Running → Ready.
• Transition 3 occurs when all other processes have had their share and
it is time for the first process to run again This state transition is:
Dispatch (process-name): Ready → Running.
• Transition 4 occurs when the external event for which a process was
waiting (such as arrival of input) happens. This state transition is:
Wakeup (process-name): Blocked → Ready.
• Transition 5 occurs when the process is created. This state transition
is:
Admitted (process-name): New → Ready.
• Transition 6 occurs when the process has finished execution. This
state transition is:
Exit (process-name): Running → Terminated.
Process State Transition Diagram
• An active process is normally in one of the five states in the diagram. The arrows
show how the process changes states.
• A process is running if the process is assigned to a CPU. A process is removed
from the running state by the scheduler if a process with a higher priority
becomes runnable. A process is also pre-empted if a process of equal priority is
runnable when the original process consumes its entire time slice.
• A process is runnable in memory if the process is in primary memory and ready
to run, but is not assigned to a CPU.
• A process is sleeping in memory if the process is in primary memory but is
waiting for a specific event before continuing execution. For example, a process
sleeps while waiting for an I/O operation to complete, for a locked resource to be
unlocked, or for a timer to expire. When the event occurs, a wakeup call is sent to
the process. If the reason for its sleep is gone, the process becomes runnable.
• When a process' address space has been written to secondary memory, and that
process is not waiting for a specific event, the process is runnable and swapped.
• If a process is waiting for a specific event and has had its whole address
space written to secondary memory, the process is sleeping and swapped.
• If a machine does not have enough primary memory to hold all its active
processes, that machine must page or swap some address space to
secondary memory.
• When the system is short of primary memory, the system writes individual
pages of some processes to secondary memory but leaves those processes
runnable. When a running process, accesses those pages, the process
sleeps while the pages are read back into primary memory.
• When the system encounters a more serious shortage of primary memory,
the system writes all the pages of some processes to secondary memory.
The system marks the pages that have been written to secondary memory
as swapped. Such processes can only be scheduled when the system
scheduler daemon selects these processes to be read back into memory.
Process Operations
Process Creation
• In general-purpose systems, some way is needed to create processes
as needed during operation.
• There are four principal events led to processes creation.
System initialization.
Execution of a process Creation System calls by a running process.
A user request to create a new process.
Initialization of a batch job.
• Background processes that stay in background sleeping but suddenly springing to life to
handle activity such as email, webpage, printing, and so on.
• Background processes are called daemons. This call creates an exact clone of the calling
process.
• A process may create a new process by some create process such as 'fork'.
• Creating process is called parent process and the created one is called the child
processes.
• Only one parent is needed to create a child process.
• Note that unlike plants and animals that use sexual representation, a process has only
one parent.
• This creation of process (processes) yields a hierarchical structure of processes.
• Notice that each child has only one parent but each parent may have many children.
• After the fork, the two processes, the parent and the child, have the same memory
image, the same environment strings and the same open files.
• After a process is created, both the parent and child have their own distinct address
space.
• If either process changes a word in its address space, the change is not visible to the
other process.
• Following are some reasons for creation of a process
User logs on.
User starts a program.
Operating systems creates process to provide service,
e.g., to manage printer.
Some program starts another process, e.g., Netscape
calls xv to display a picture.
Process Termination
• A process terminates when it finishes executing its last statement.
• Its resources are returned to the system, it is purged from any system lists or tables,
and its process control block (PCB) is erased i.e., the PCB's memory space is returned
to a free memory pool.
• The new process terminates the existing process, usually due to following reasons:
Normal Exist Most processes terminates because they have done their job. This call is
exist in UNIX.
Error Exist When process discovers a fatal error. For example, a user tries to compile a
program that does not exist.
Fatal Error An error caused by process due to a bug in program for example, executing
an illegal instruction, referring non-existing memory or dividing by zero.
Killed by another Process A process executes a system call telling the Operating
Systems to terminate some other process. In UNIX, this call is kill. In some systems
when a process kills all processes it created are killed as well (UNIX does not work this
way).
Process Control Block
• A Process Control Block (PCB) is a data structure maintained by the
Operating System for every process.
• The PCB is identified by an integer process ID (PID).
• A PCB keeps all the information needed to keep track of a process as
listed below in the table:
Simplified PCB Diagram
PCB ctd’
• The architecture of a PCB is completely dependent on Operating
System and may contain different information in different operating
systems.
• The PCB is maintained for a process throughout its lifetime, and is
deleted once the process terminates.
Context Switching
• Process Context = machine environment
during the time the process is actively
using the CPU.
• i.e. context includes program counter,
general purpose registers, processor status
register (with C,N,V and Z flags), . . .
• To switch between processes, the OS
must:
a) save the context of the currently
executing process (if any), and
b) restore the context of that being
resumed.
• Time taken depends on h/w support.
Idle system
• What do we do if there is no ready process?
 halt processor (until interrupt arrives)
 saves power (and heat!)
 increases processor lifetime
 might take too long to stop and start.
• busy wait in scheduler
 quick response time
 ugly, useless
• invent idle process, always available to run
 gives uniform structure
 could use it to run checks
 uses some memory
 can slow interrupt response
• In general there is a trade-off between responsiveness and usefulness.

Mais conteúdo relacionado

Mais procurados

File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating SystemJanki Shah
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Mukesh Chinta
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocksmyrajendra
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its conceptsKaran Thakkar
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memorysgpraju
 
Linux process management
Linux process managementLinux process management
Linux process managementRaghu nath
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System CallsVandana Salve
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.MOHIT DADU
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria myrajendra
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationShivam Mitra
 
Operating system 18 process creation and termination
Operating system 18 process creation and terminationOperating system 18 process creation and termination
Operating system 18 process creation and terminationVaibhav Khanna
 

Mais procurados (20)

File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)Process scheduling (CPU Scheduling)
Process scheduling (CPU Scheduling)
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
12 process control blocks
12 process control blocks12 process control blocks
12 process control blocks
 
System calls
System callsSystem calls
System calls
 
Operating system - Process and its concepts
Operating system - Process and its conceptsOperating system - Process and its concepts
Operating system - Process and its concepts
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
Cpu scheduling
Cpu schedulingCpu scheduling
Cpu scheduling
 
Linux process management
Linux process managementLinux process management
Linux process management
 
Introduction to System Calls
Introduction to System CallsIntroduction to System Calls
Introduction to System Calls
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria 17 cpu scheduling and scheduling criteria
17 cpu scheduling and scheduling criteria
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
 
Scheduling algorithms
Scheduling algorithmsScheduling algorithms
Scheduling algorithms
 
Operating system 18 process creation and termination
Operating system 18 process creation and terminationOperating system 18 process creation and termination
Operating system 18 process creation and termination
 
Operating system basics
Operating system basicsOperating system basics
Operating system basics
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 

Semelhante a Lecture 2 process

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
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxAmanuelmergia
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdfAmanuelmergia
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentationchnrketan
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management JayeshGadhave1
 
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
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of ProcessShipra Swati
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptxDivyaKS18
 
Process , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsProcess , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsAhsanRazaKolachi
 
opearating system notes mumbai university.pptx
opearating system notes mumbai university.pptxopearating system notes mumbai university.pptx
opearating system notes mumbai university.pptxssuser3dfcef
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...morganjohn3
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfnikhil287188
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfFahanaAbdulVahab
 

Semelhante a Lecture 2 process (20)

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
 
Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptx
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdf
 
UNIT I-Processes.pptx
UNIT I-Processes.pptxUNIT I-Processes.pptx
UNIT I-Processes.pptx
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 
Unit 2_OS process management
Unit 2_OS process management Unit 2_OS process management
Unit 2_OS process management
 
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...
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Processing management
Processing managementProcessing management
Processing management
 
PROCESS.pptx
PROCESS.pptxPROCESS.pptx
PROCESS.pptx
 
Process , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsProcess , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating Systems
 
Processes
ProcessesProcesses
Processes
 
opearating system notes mumbai university.pptx
opearating system notes mumbai university.pptxopearating system notes mumbai university.pptx
opearating system notes mumbai university.pptx
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdf
 
Process Management
Process ManagementProcess Management
Process Management
 
Operating System.pptx
Operating System.pptxOperating System.pptx
Operating System.pptx
 
Lecture5
Lecture5Lecture5
Lecture5
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdf
 

Último

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Último (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Lecture 2 process

  • 2. Objectives • At the end of this topic, students should be able to: • Define a Process • Describe a Process State • Describe the Process Operations • Explain a Process Control Block (PCB)
  • 3. Process • a process is an instance of a computer program that is being executed. • It contains the program code and its current activity. • The execution of a process must progress in a sequential fashion. • A process is defined as an entity which represents the basic unit of work to be implemented in the system. • To put it in simple terms, 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. • When a program is loaded into the memory and it becomes a process, it can be divided into four sections ─ stack, heap, text and data.
  • 5.
  • 6. Program • A program is a piece of code which may be a single line or millions of lines. • A computer program is usually written by a computer programmer in a programming language. • For example, here is a simple program written in C programming language:
  • 7. Processes vs. Programs • A process is different than a program • Program: Static code and static data • Process: Dynamic instance of code and data • No one-to-one mapping between programs and processes • Can have multiple processes of the same program: Example: many users can run “ls” at the same time • One program can invoke multiple processes: Example: “make” runs many processes to accomplish its work
  • 8. Process Life Cycle/ Process State • When a process executes, it passes through different states. • These stages may differ in different operating systems, and the names of these states are also not standardized. • In general, a process can have one of the following five states at a time.
  • 9. Processes can be any of the following states : • Start/New - The process is at the initial stage of being created. • Ready - The process is waiting to be assigned to a processor. Ready processes are waiting to have the processor allocated to them by the operating system so that they can run. Process may come into this state after Start state or while running it by but interrupted by the scheduler to assign CPU to some other process. • Running - The CPU is working on this process's instructions. Once the process has been assigned to a processor by the OS scheduler, the process state is set to running and the processor executes its instructions. • Waiting - Process moves into the waiting state if it needs to wait for a resource, such as waiting for user input, or waiting for a file to become available. • Termination/ Exit - Once the process finishes its execution or it is terminated by the operating system, it is moved to the terminated state where it waits to be removed from main memory. The process has completed.
  • 11. Process State Transitions • Following are six(6) possible transitions among above mentioned five (5) states • Transition 1 occurs when process discovers that it cannot continue. If running process initiates an I/O operation before its allotted time expires, the running process voluntarily relinquishes the CPU. This state transition is: Block (process-name): Running → Blocked • Transition 2 occurs when the scheduler decides that the running process has run long enough and it is time to let another process have CPU time. This state transition is: Time-Run-Out (process-name): Running → Ready.
  • 12. • Transition 3 occurs when all other processes have had their share and it is time for the first process to run again This state transition is: Dispatch (process-name): Ready → Running. • Transition 4 occurs when the external event for which a process was waiting (such as arrival of input) happens. This state transition is: Wakeup (process-name): Blocked → Ready. • Transition 5 occurs when the process is created. This state transition is: Admitted (process-name): New → Ready. • Transition 6 occurs when the process has finished execution. This state transition is: Exit (process-name): Running → Terminated.
  • 14. • An active process is normally in one of the five states in the diagram. The arrows show how the process changes states. • A process is running if the process is assigned to a CPU. A process is removed from the running state by the scheduler if a process with a higher priority becomes runnable. A process is also pre-empted if a process of equal priority is runnable when the original process consumes its entire time slice. • A process is runnable in memory if the process is in primary memory and ready to run, but is not assigned to a CPU. • A process is sleeping in memory if the process is in primary memory but is waiting for a specific event before continuing execution. For example, a process sleeps while waiting for an I/O operation to complete, for a locked resource to be unlocked, or for a timer to expire. When the event occurs, a wakeup call is sent to the process. If the reason for its sleep is gone, the process becomes runnable. • When a process' address space has been written to secondary memory, and that process is not waiting for a specific event, the process is runnable and swapped.
  • 15. • If a process is waiting for a specific event and has had its whole address space written to secondary memory, the process is sleeping and swapped. • If a machine does not have enough primary memory to hold all its active processes, that machine must page or swap some address space to secondary memory. • When the system is short of primary memory, the system writes individual pages of some processes to secondary memory but leaves those processes runnable. When a running process, accesses those pages, the process sleeps while the pages are read back into primary memory. • When the system encounters a more serious shortage of primary memory, the system writes all the pages of some processes to secondary memory. The system marks the pages that have been written to secondary memory as swapped. Such processes can only be scheduled when the system scheduler daemon selects these processes to be read back into memory.
  • 16. Process Operations Process Creation • In general-purpose systems, some way is needed to create processes as needed during operation. • There are four principal events led to processes creation. System initialization. Execution of a process Creation System calls by a running process. A user request to create a new process. Initialization of a batch job.
  • 17. • Background processes that stay in background sleeping but suddenly springing to life to handle activity such as email, webpage, printing, and so on. • Background processes are called daemons. This call creates an exact clone of the calling process. • A process may create a new process by some create process such as 'fork'. • Creating process is called parent process and the created one is called the child processes. • Only one parent is needed to create a child process. • Note that unlike plants and animals that use sexual representation, a process has only one parent. • This creation of process (processes) yields a hierarchical structure of processes. • Notice that each child has only one parent but each parent may have many children. • After the fork, the two processes, the parent and the child, have the same memory image, the same environment strings and the same open files. • After a process is created, both the parent and child have their own distinct address space. • If either process changes a word in its address space, the change is not visible to the other process.
  • 18. • Following are some reasons for creation of a process User logs on. User starts a program. Operating systems creates process to provide service, e.g., to manage printer. Some program starts another process, e.g., Netscape calls xv to display a picture.
  • 19. Process Termination • A process terminates when it finishes executing its last statement. • Its resources are returned to the system, it is purged from any system lists or tables, and its process control block (PCB) is erased i.e., the PCB's memory space is returned to a free memory pool. • The new process terminates the existing process, usually due to following reasons: Normal Exist Most processes terminates because they have done their job. This call is exist in UNIX. Error Exist When process discovers a fatal error. For example, a user tries to compile a program that does not exist. Fatal Error An error caused by process due to a bug in program for example, executing an illegal instruction, referring non-existing memory or dividing by zero. Killed by another Process A process executes a system call telling the Operating Systems to terminate some other process. In UNIX, this call is kill. In some systems when a process kills all processes it created are killed as well (UNIX does not work this way).
  • 20. Process Control Block • A Process Control Block (PCB) is a data structure maintained by the Operating System for every process. • The PCB is identified by an integer process ID (PID). • A PCB keeps all the information needed to keep track of a process as listed below in the table:
  • 21.
  • 22.
  • 24. PCB ctd’ • The architecture of a PCB is completely dependent on Operating System and may contain different information in different operating systems. • The PCB is maintained for a process throughout its lifetime, and is deleted once the process terminates.
  • 25. Context Switching • Process Context = machine environment during the time the process is actively using the CPU. • i.e. context includes program counter, general purpose registers, processor status register (with C,N,V and Z flags), . . . • To switch between processes, the OS must: a) save the context of the currently executing process (if any), and b) restore the context of that being resumed. • Time taken depends on h/w support.
  • 26. Idle system • What do we do if there is no ready process?  halt processor (until interrupt arrives)  saves power (and heat!)  increases processor lifetime  might take too long to stop and start. • busy wait in scheduler  quick response time  ugly, useless • invent idle process, always available to run  gives uniform structure  could use it to run checks  uses some memory  can slow interrupt response • In general there is a trade-off between responsiveness and usefulness.