SlideShare uma empresa Scribd logo
1 de 31
Rushdi Shams, Dept of CSE, KUET 1
“There are 10 types of people in the world- who understands binary
and who does not”
Process Concept
 Process is a program in execution; process
execution must progress in sequential fashion
 A process includes:
1. Text Section: Program code. Text files have a
program code which is different than program
codes of E-mail programs
2. Program counter: Represents the current state
of the process
3. Stack: Contains temporary data like method
parameters, return addresses
4. Data section: Contains global variables
Rushdi Shams, Dept of CSE, KUET 2
Process State
 As a process executes, it changes state. This
state is noticed by the program counter.
new: The process is being created
running: Instructions are being executed
waiting: The process is waiting for some event to
occur
ready: The process is waiting to be assigned to a
processor
terminated: The process has finished execution
Rushdi Shams, Dept of CSE, KUET 3
Diagram of Process State
Rushdi Shams, Dept of CSE, KUET 4
Process Control Block (PCB)
Information associated with each
process
 Process state
 Program counter
 CPU registers
 CPU scheduling information
 Memory-management information
 I/O status information
Rushdi Shams, Dept of CSE, KUET 5
Process Control Block (PCB)
6Rushdi Shams, Dept of CSE, KUET
CPU Switch From Process to
Process
7Rushdi Shams, Dept of CSE, KUET
Process Scheduling Queues
 Job queue – set of all processes in the
system
 Ready queue – set of all processes residing
in main memory, ready and waiting to execute
 Device queues – set of processes waiting for
an I/O device
 Processes migrate among the various queues
Rushdi Shams, Dept of CSE, KUET 8
Representation of Process
Scheduling
9Rushdi Shams, Dept of CSE, KUET
Schedulers
 Long-term scheduler (or job
scheduler) – selects which processes
should be brought into the ready queue
 Short-term scheduler (or CPU
scheduler) – selects which process
should be executed next and allocates
CPU
Rushdi Shams, Dept of CSE, KUET 10
Schedulers (Cont.)
 Short-term scheduler is invoked very
frequently
milliseconds
must be fast
 Long-term scheduler is invoked very
infrequently
seconds, minutes
may be slow
 The long-term scheduler controls the
degree of multiprogramming
Rushdi Shams, Dept of CSE, KUET 11
Mathematics!
 If a process is required 10 milliseconds to be
decided for a GO and it takes 100 milliseconds
to execute then the CPU usage for that
particular task is-
110 ms process requires 10 ms to be decided
1 ms process requires 10/110 ms to be decided
100 ms process requires ??? ms to be decided
9% of the CPU was used to accomplish that
process
Rushdi Shams, Dept of CSE, KUET 12
Mathematics!
 If a process is required 100 seconds to be
decided for a GO and it takes 1000 seconds to
execute then the CPU usage for that particular
task is-
1100 s process requires 100 s to be decided
1 s process requires 100/1100 s to be decided
100 s process requires ??? s to be decided
9% of the CPU was used to accomplish that
process
Rushdi Shams, Dept of CSE, KUET 13
Mathematics!
 Which process should be scheduled
by Long term scheduler? Justify your
statement
Rushdi Shams, Dept of CSE, KUET 14
The Process Model
 Conceptually, each process has its own
virtual CPU
 In reality, the real CPU switches back
and forth from process to process
 This procedure is called
pseudoparallelism.
Rushdi Shams, Dept of CSE, KUET 15
Rushdi Shams, Dept of CSE, KUET 16
Rushdi Shams, Dept of CSE, KUET 17
 A Computer Engineer is making cake
today.
 In his kitchen, he has a book- “how to
bake cake”
 He also has ingredients like- flour,
baking soda, custard powder, etc.
Rushdi Shams, Dept of CSE, KUET 18
 The book is the program (algorithm)
 The computer engineer is the CPU
 The ingredients are input data
(remember global and local variables??)
 The process is the activity consisting of
our baker reading the book, fetching the
ingredient and baking the cake!
Rushdi Shams, Dept of CSE, KUET 19
 Now, his youngest son came to the
kitchen
 He alleged to his father that he has been
attacked by cockroaches and they had a
bite on him!
 His father stops baking
 The computer engineer took the first aid
box and aided his son
Rushdi Shams, Dept of CSE, KUET 20
 The son is the interrupt program
 The first aid box is a different program
 The injection, medicines in the box are
data need to run the program
 And of course, aiding son is more high
prioritized process than baking cakes!
 The engineer after aiding his son comes
back to the kitchen and then again
bakes cakes!
Rushdi Shams, Dept of CSE, KUET 21
Process Creation
 Three principal reasons for which a
process is created.
1. System initialization
when the OS is booted, several
processes are created. Some of them
are foreground processes, others are
background processes.
Rushdi Shams, Dept of CSE, KUET 22
 Background processes designed to deal
with incoming mails sleep. Whenever a
mail comes, they wake.
 Processes that stay in background to
handle some activity like email, web
pages, printing are called Daemons.
Rushdi Shams, Dept of CSE, KUET 23
Process Creation
2. Process created by other process
mostly done by system calls. In
network sharing, one process may
collect the stream of bytes and store
them, other maintains the buffer while
introduced by the first one.
Rushdi Shams, Dept of CSE, KUET 24
Process Creation
3. Process created by a user request
Whatever you click and do on Windows
platform, with every single click, there
is a possibility to create a new thread!!

Rushdi Shams, Dept of CSE, KUET 25
Process Creation
 In UNIX, there is only one system call to
create new process: FORK
 This call creates an exact clone of the
calling process.
 After the FORK, two processes- child and
parent have the same memory image,
environment strings, same everything!
 The child process then executes EXECVE
to change its memory image and run a
new program
Rushdi Shams, Dept of CSE, KUET 26
Process Creation
 The reason for this two step process is
like a reservation in bus ticket. The OS
is alerted that with the procedure.
Secondly, the child process gets plenty
of time to decide whether it’s going to
purchase or decline that ticket!
 Windows does not have such
FORKING. It uses CreateProcess
system call and the child is created
straight away!
Rushdi Shams, Dept of CSE, KUET 27
Process Termination
 Sooner or later the new process will
terminate-
1. Normal Exit (voluntary)
Simply, when you close a window on
Windows, the process(es) related to it
have their normal exit
Rushdi Shams, Dept of CSE, KUET 28
Process Termination
2. Error Exit (voluntary)
 How many times your compiler
reported error to you during compiling?
 Screen oriented platforms like
Windows, however, uses a hybrid of
Normal Exit and Error Exit in such
cases!
Rushdi Shams, Dept of CSE, KUET 29
Process Termination
3. Fatal Error (Non-voluntary)
this error is caused by the process
itself, normally due to the program bug.
Referencing non-existing memory
location or divide by zero problems
cause such errors and process
termination
Rushdi Shams, Dept of CSE, KUET 30
Process Termination
4. Killed by another process
In UNIX, the system call is KILL. In
Windows, the call is TerminateProcess.
In both cases, the KILLER must have
the proper authorization to kill the
KILLEE.
 In some systems, when a process
terminates, all processes it creates die.
UNIX and Windows-none of them
works in this fashion.
Rushdi Shams, Dept of CSE, KUET 31

Mais conteúdo relacionado

Destaque

Lec 15. Pointers and Arrays
Lec 15. Pointers and ArraysLec 15. Pointers and Arrays
Lec 15. Pointers and Arrays
Rushdi Shams
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)
Rushdi Shams
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
Rushdi Shams
 
Lec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by ValuesLec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by Values
Rushdi Shams
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
Rushdi Shams
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrity
Rushdi Shams
 
Research methodology
Research methodologyResearch methodology
Research methodology
Rushdi Shams
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
Rushdi Shams
 
L7 data model and dbms architecture
L7  data model and dbms architectureL7  data model and dbms architecture
L7 data model and dbms architecture
Rushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
Rushdi Shams
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
Rushdi Shams
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
Rushdi Shams
 

Destaque (15)

Lec 15. Pointers and Arrays
Lec 15. Pointers and ArraysLec 15. Pointers and Arrays
Lec 15. Pointers and Arrays
 
Lec 19. Structure
Lec 19. StructureLec 19. Structure
Lec 19. Structure
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
Lec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by ValuesLec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by Values
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrity
 
Research methodology
Research methodologyResearch methodology
Research methodology
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
 
Normal forms
Normal formsNormal forms
Normal forms
 
L7 data model and dbms architecture
L7  data model and dbms architectureL7  data model and dbms architecture
L7 data model and dbms architecture
 
L3 defense
L3  defenseL3  defense
L3 defense
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 

Semelhante a Lecture 1 and 2 processes

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
 
Lecture 3 and 4 threads
Lecture 3 and 4  threadsLecture 3 and 4  threads
Lecture 3 and 4 threads
Rushdi Shams
 
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
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
tech2click
 

Semelhante a Lecture 1 and 2 processes (20)

Cs8493 unit 2
Cs8493 unit 2Cs8493 unit 2
Cs8493 unit 2
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
 
CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2CS6401 OPERATING SYSTEMS Unit 2
CS6401 OPERATING SYSTEMS Unit 2
 
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
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Lecture 3 and 4 threads
Lecture 3 and 4  threadsLecture 3 and 4  threads
Lecture 3 and 4 threads
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Ch03- PROCESSES.ppt
Ch03- PROCESSES.pptCh03- PROCESSES.ppt
Ch03- PROCESSES.ppt
 
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
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
CH03.pdf
CH03.pdfCH03.pdf
CH03.pdf
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
 
Managing Processes in Unix.pptx
Managing Processes in Unix.pptxManaging Processes in Unix.pptx
Managing Processes in Unix.pptx
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
 
Analysis Of Process Structure In Windows Operating System
Analysis Of Process Structure In Windows Operating SystemAnalysis Of Process Structure In Windows Operating System
Analysis Of Process Structure In Windows Operating System
 
3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdf3330701_unit-1_operating-system-concepts.pdf
3330701_unit-1_operating-system-concepts.pdf
 
OS-Process.pdf
OS-Process.pdfOS-Process.pdf
OS-Process.pdf
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)OperatingSystem02..(B.SC Part 2)
OperatingSystem02..(B.SC Part 2)
 

Mais de Rushdi Shams

L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
Rushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
Rushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
Rushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
Rushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
Rushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
Rushdi Shams
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
Rushdi Shams
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
Rushdi Shams
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Rushdi Shams
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
Rushdi Shams
 

Mais de Rushdi Shams (20)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 

Último (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Lecture 1 and 2 processes

  • 1. Rushdi Shams, Dept of CSE, KUET 1 “There are 10 types of people in the world- who understands binary and who does not”
  • 2. Process Concept  Process is a program in execution; process execution must progress in sequential fashion  A process includes: 1. Text Section: Program code. Text files have a program code which is different than program codes of E-mail programs 2. Program counter: Represents the current state of the process 3. Stack: Contains temporary data like method parameters, return addresses 4. Data section: Contains global variables Rushdi Shams, Dept of CSE, KUET 2
  • 3. Process State  As a process executes, it changes state. This state is noticed by the program counter. new: The process is being created running: Instructions are being executed waiting: The process is waiting for some event to occur ready: The process is waiting to be assigned to a processor terminated: The process has finished execution Rushdi Shams, Dept of CSE, KUET 3
  • 4. Diagram of Process State Rushdi Shams, Dept of CSE, KUET 4
  • 5. Process Control Block (PCB) Information associated with each process  Process state  Program counter  CPU registers  CPU scheduling information  Memory-management information  I/O status information Rushdi Shams, Dept of CSE, KUET 5
  • 6. Process Control Block (PCB) 6Rushdi Shams, Dept of CSE, KUET
  • 7. CPU Switch From Process to Process 7Rushdi Shams, Dept of CSE, KUET
  • 8. Process Scheduling Queues  Job queue – set of all processes in the system  Ready queue – set of all processes residing in main memory, ready and waiting to execute  Device queues – set of processes waiting for an I/O device  Processes migrate among the various queues Rushdi Shams, Dept of CSE, KUET 8
  • 10. Schedulers  Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue  Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU Rushdi Shams, Dept of CSE, KUET 10
  • 11. Schedulers (Cont.)  Short-term scheduler is invoked very frequently milliseconds must be fast  Long-term scheduler is invoked very infrequently seconds, minutes may be slow  The long-term scheduler controls the degree of multiprogramming Rushdi Shams, Dept of CSE, KUET 11
  • 12. Mathematics!  If a process is required 10 milliseconds to be decided for a GO and it takes 100 milliseconds to execute then the CPU usage for that particular task is- 110 ms process requires 10 ms to be decided 1 ms process requires 10/110 ms to be decided 100 ms process requires ??? ms to be decided 9% of the CPU was used to accomplish that process Rushdi Shams, Dept of CSE, KUET 12
  • 13. Mathematics!  If a process is required 100 seconds to be decided for a GO and it takes 1000 seconds to execute then the CPU usage for that particular task is- 1100 s process requires 100 s to be decided 1 s process requires 100/1100 s to be decided 100 s process requires ??? s to be decided 9% of the CPU was used to accomplish that process Rushdi Shams, Dept of CSE, KUET 13
  • 14. Mathematics!  Which process should be scheduled by Long term scheduler? Justify your statement Rushdi Shams, Dept of CSE, KUET 14
  • 15. The Process Model  Conceptually, each process has its own virtual CPU  In reality, the real CPU switches back and forth from process to process  This procedure is called pseudoparallelism. Rushdi Shams, Dept of CSE, KUET 15
  • 16. Rushdi Shams, Dept of CSE, KUET 16
  • 17. Rushdi Shams, Dept of CSE, KUET 17
  • 18.  A Computer Engineer is making cake today.  In his kitchen, he has a book- “how to bake cake”  He also has ingredients like- flour, baking soda, custard powder, etc. Rushdi Shams, Dept of CSE, KUET 18
  • 19.  The book is the program (algorithm)  The computer engineer is the CPU  The ingredients are input data (remember global and local variables??)  The process is the activity consisting of our baker reading the book, fetching the ingredient and baking the cake! Rushdi Shams, Dept of CSE, KUET 19
  • 20.  Now, his youngest son came to the kitchen  He alleged to his father that he has been attacked by cockroaches and they had a bite on him!  His father stops baking  The computer engineer took the first aid box and aided his son Rushdi Shams, Dept of CSE, KUET 20
  • 21.  The son is the interrupt program  The first aid box is a different program  The injection, medicines in the box are data need to run the program  And of course, aiding son is more high prioritized process than baking cakes!  The engineer after aiding his son comes back to the kitchen and then again bakes cakes! Rushdi Shams, Dept of CSE, KUET 21
  • 22. Process Creation  Three principal reasons for which a process is created. 1. System initialization when the OS is booted, several processes are created. Some of them are foreground processes, others are background processes. Rushdi Shams, Dept of CSE, KUET 22
  • 23.  Background processes designed to deal with incoming mails sleep. Whenever a mail comes, they wake.  Processes that stay in background to handle some activity like email, web pages, printing are called Daemons. Rushdi Shams, Dept of CSE, KUET 23
  • 24. Process Creation 2. Process created by other process mostly done by system calls. In network sharing, one process may collect the stream of bytes and store them, other maintains the buffer while introduced by the first one. Rushdi Shams, Dept of CSE, KUET 24
  • 25. Process Creation 3. Process created by a user request Whatever you click and do on Windows platform, with every single click, there is a possibility to create a new thread!!  Rushdi Shams, Dept of CSE, KUET 25
  • 26. Process Creation  In UNIX, there is only one system call to create new process: FORK  This call creates an exact clone of the calling process.  After the FORK, two processes- child and parent have the same memory image, environment strings, same everything!  The child process then executes EXECVE to change its memory image and run a new program Rushdi Shams, Dept of CSE, KUET 26
  • 27. Process Creation  The reason for this two step process is like a reservation in bus ticket. The OS is alerted that with the procedure. Secondly, the child process gets plenty of time to decide whether it’s going to purchase or decline that ticket!  Windows does not have such FORKING. It uses CreateProcess system call and the child is created straight away! Rushdi Shams, Dept of CSE, KUET 27
  • 28. Process Termination  Sooner or later the new process will terminate- 1. Normal Exit (voluntary) Simply, when you close a window on Windows, the process(es) related to it have their normal exit Rushdi Shams, Dept of CSE, KUET 28
  • 29. Process Termination 2. Error Exit (voluntary)  How many times your compiler reported error to you during compiling?  Screen oriented platforms like Windows, however, uses a hybrid of Normal Exit and Error Exit in such cases! Rushdi Shams, Dept of CSE, KUET 29
  • 30. Process Termination 3. Fatal Error (Non-voluntary) this error is caused by the process itself, normally due to the program bug. Referencing non-existing memory location or divide by zero problems cause such errors and process termination Rushdi Shams, Dept of CSE, KUET 30
  • 31. Process Termination 4. Killed by another process In UNIX, the system call is KILL. In Windows, the call is TerminateProcess. In both cases, the KILLER must have the proper authorization to kill the KILLEE.  In some systems, when a process terminates, all processes it creates die. UNIX and Windows-none of them works in this fashion. Rushdi Shams, Dept of CSE, KUET 31