SlideShare a Scribd company logo
1 of 34
Chapter 3: Processes
3.1 Process Concept
 Early operating systems allowed only one program to be executed at a time. This
program had complete control of the system.
 Current-day OS allow multiple programs to be loaded and executed concurrently
with the CPU(CPUs) multiplexed among them.
 Textbook uses the terms job and process almost interchangeably
 Process – is a program in execution; it is more than program code (called text
section).
 A process includes the current activity represented by the value of:
 program counter
 Processor’s registers
 Stack, which contains temporary data( such as function parameters, return
addresses and local variables)
 data section which contains global variables
 Heap which is memory that is dynamically allocated during process run time.
 A program by itself is not a process; it is a passive entity such as a file containing
a list of instructions stored on disk (often called executable file), whereas a
process is an active entity. A program becomes a process when an executable file
is loaded into memory either by double-clicking the program’s icon or entering the
name of the executable file on the CLI.
3.1 Process Concept…..
 Although two processes may be associated with the same program, they are
nevertheless considered two separate execution sequences. Although the text
sections are equivalent, the data, heap, and stack sections vary. Example: a user
may invoke many copies of a web-browser program.
 The diagram below shows a process in memory
3.2 Process State
 The state of a process is defined in part by the current activity of that process. As a process
executes, it changes state
 new: The process is being created
 running: Instructions are being executed
 waiting: The process is waiting for some event to occur(such as an I/O completion or
reception of a signal)
 ready: The process is waiting to be assigned to a processor
 terminated: The process has finished execution
 Note: only one process can be running on any processor at any instant. Many processes
may be ready and waiting however.
3.3 Process Control Block (PCB)
Each process is represented in the OS by PCB also called task control block.
Information associated with each process are:
 Process state: new, ready, running, waiting, halted…
 Program counter(PC): indicates the address of the next instruction to be
executed for this process.
 CPU registers: along with PC, this state information must be saved when an
interrupt occurs to allow the process be continued correctly afterward.
 CPU scheduling information: includes process priority, pointers to scheduling
queues and other scheduling parameters.
 Memory-management information: includes the value of base and limit
registers, page tables/segment tables and so on.
 Accounting information: includes amount of CPU and real time used, time
limits, account numbers, process numbers etc.
 I/O status information: includes the list of I/O devices allocated to the process, a
list of open files and so on.
CPU Switch From Process to Process
3.4 Process Scheduling
The objective of multiprogramming is to have some processes running at all times, to
maximize CPU utilization. The objective of time sharing is to switch the CPU among
processes so frequently that users can interact with each program while it is running.
Scheduling Queues
 Job queue – set of all processes in the system
 Ready queue – list of all processes residing in main memory, ready and waiting
to execute
 Device queues – list of processes waiting for an I/O device
 Processes migrate among the various queues
Ready Queue And Various I/O Device Queues
Representation of Process Scheduling
3.5 Schedulers
 Long-term scheduler (or job scheduler) – selects which processes should be
brought into the memory(ready queue).
 Short-term scheduler (or CPU scheduler) – selects from among the processes
that are ready to execute and allocates CPU to one of them
 Difference between these two schedulers lies in frequency of execution
 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 (the number of
processes in memory)
 Processes can be described as either:
 I/O-bound process – spends more time doing I/O than computations, many
short CPU bursts
 CPU-bound process – spends more time doing computations; few very long
CPU bursts
Addition of Medium Term Scheduling
Context Switch
 Interrupts cause the OS to change a CPU from its current task and
to run a kernel routine. The system must save the state of the
process currently running and load the saved state (state restore)
for the new process.
 Context-switch time is overhead because the system does no
useful work while switching
 Context-switch times are dependent on hardware support.
Example: the set of registers in the system.
3.6 Operations on Processes
3.6.1 Process Creation
 Parent process create children processes, which, in turn create other processes,
forming a tree of processes
 To accomplish its tasks, a process will need certain resources which it will obtain
directly from OS or parent process.
 Resource sharing
 Parent and children share all resources
 Children share subset of parent’s resources
 Parent and child share no resources
 Restricting a child process to a subset of the parent’s resources prevents any
process from overloading the system by creating too many sub processes.
 Two possibilities in terms of execution
 Parent and children execute concurrently
 Parent waits until children terminate
 Two possibilities in terms of address space
 Child duplicate of parent(it has the same program and data as the parent)
 Child has a program loaded into it
Process Creation (Cont.)
 UNIX examples
 fork system call creates new process
 exec system call used after a fork to replace the process’ memory
space with a new program
A tree of processes on a typical Solaris
3.6.2 Process Termination
 A process terminates when it finishes its last statement and asks
the operating system to delete it (by using the exit() system call).
 The process may return a status value to its parent process
(via wait() system call).
 Process’ resources are deallocated by operating system
 Parent may terminate execution of its children processes using
appropriate system call (abort) for various reasons such as :
 Child has exceeded allocated resources
 Task assigned to child is no longer required
 If parent is exiting
 Some operating system do not allow child to continue if its
parent terminates
– All children terminated - cascading termination
3.7 Cooperating Processes
 Independent process cannot affect or be affected by the execution of another
process(does not share data with any other process).
 Cooperating process can affect or be affected by the execution of another
process(shares data with other process)
 Advantages of process cooperation
 Information sharing: several users may need same information
 Computation speed-up: enables parallel execution
 Modularity
 Convenience
 Cooperating processes require an inter process communication (IPC)
mechanism to exchange data and information. Two models of IPC are
 Shared memory
 Message passing
3.7.1 Shared Memory
 Processes can exchange information by reading and writing data to a
shared memory region established by the cooperating processes.
 A shared memory region resides in the address space of the process
creating it. The other processes that wish to communicate attach it to their
address space.
 Allows maximum speed and convenience of communication as it can be
done at memory speeds when within a computer.
 System calls are required only to establish shared memory regions and no
assistance from the kernel is required to access the shared memory.
 Producer-consumer problem: paradigm for cooperating processes,
producer process produces information that is consumed by a consumer
process. One solution is to use buffer
 unbounded-buffer places no practical limit on the size of the buffer
 bounded-buffer assumes that there is a fixed buffer size
Communications Models
Fig. IPC a) message passing b) shared-memory
3.7.2 Message Passing
 Communication takes place by means of messages exchanged between the
cooperating processes. Example : a chat program used on WWW
 Useful for exchanging smaller amount of data
 Easier to implement than shared-memory for inter computer communication
 Typically implemented using system calls and thus require more time-consuming
task of OS intervention.
 Message-passing facility provides two operations:
 send(message) – message size can be either fixed or variable
 receive(message)
 If P and Q wish to communicate, they need to:
 establish a communication link between them
 exchange messages via send/receive
 Implementation of logical communication link
 physical (e.g., shared memory, hardware bus)
 logical (e.g., logical properties)
Implementation Questions
 How are links established?
 Can a link be associated with more than two processes?
 How many links can there be between every pair of communicating
processes?
 What is the capacity of a link?
 Is the size of a message that the link can accommodate fixed or
variable?
 Is a link unidirectional or bi-directional?
3.7.2.1 Direct Communication
 Processes must name each other explicitly: the send() and
receive() primitives are defined as
 send (P, message) – send a message to process P
 receive(Q, message) – receive a message from process Q
 Properties of communication link
 Links are established automatically
 A link is associated with exactly one pair of communicating
processes
 Between each pair there exists exactly one link
 The link may be unidirectional, but is usually bi-directional
3.7.2.2 Indirect Communication
 Messages are sent to and received from mailboxes (also referred to as ports)
 Each mailbox has a unique id
 Processes can communicate only if they share a mailbox
 Primitives are defined as
 send (A, message) – send a message to mailbox A
 receive(A, message) – receive a message from mailbox A
 Properties of communication link
 Link established only if processes share a common mailbox
 A link may be associated with more than two processes
 Each pair of processes may share several communication links
 Link may be unidirectional or bi-directional
3.7.2.2 Indirect Communication……..
 Mailbox sharing
 Suppose processes P1, P2, and P3 share mailbox A and P1, sends message to
A. which process will receive the message?
 Solutions depends on
 Allow a link to be associated with at most two processes
 Allow only one process at a time to execute a receive operation
 Allow the system to select arbitrarily one receiver, not both. Sender is notified
who the receiver was.
 A mailbox may be owned by a process or by OS
 OS must provide operations to
 create a new mailbox
 send and receive messages through mailbox
 destroy a mailbox
 When a process that owns a mailbox terminates, the mailbox disappears. A
mailbox owned by OS has an existence of its own.
3.7.2.3 Synchronization
 Message passing may be either blocking or non-blocking
 Blocking is considered synchronous
 Blocking send has the sender block until the message is
received by process or mailbox.
 Blocking receive has the receiver block until a message is
available
 Non-blocking is considered asynchronous
 Non-blocking send has the sender send the message and
continue
 Non-blocking receive has the receiver receive a valid
message or null
3.7.2.4 Buffering
 Queue of messages attached to the link to temporarily store
messages; implemented in one of three ways
1. Zero capacity – queue has zero length thus the link cannot
have any messages waiting in it. Sender must wait for receiver.
2. Bounded capacity – queue has finite length of n messages.
Sender must wait if link full
3. Unbounded capacity – potentially infinite length queue. Sender
never waits.
Client-Server Communication
 Sockets
 Remote Procedure Calls
 Remote Method Invocation (Java)
Sockets
 A socket is defined as an endpoint for communication
 Concatenation of IP address and port
 The socket 161.25.19.8:1625 refers to port 1625 on host
161.25.19.8
 Communication consists between a pair of sockets
Socket Communication
Remote Procedure Calls
 Remote procedure call (RPC) abstracts procedure calls between
processes on networked systems.
 Stubs – client-side proxy for the actual procedure on the server.
 The client-side stub locates the server and marshalls the
parameters.
 The server-side stub receives this message, unpacks the
marshalled parameters, and peforms the procedure on the server.
Execution of RPC
Remote Method Invocation
 Remote Method Invocation (RMI) is a Java mechanism similar to
RPCs.
 RMI allows a Java program on one machine to invoke a method on
a remote object.
Marshalling Parameters
End of Chapter 3

More Related Content

Similar to operating system for computer engineering ch3.ppt

Chapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System ConceptsChapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System ConceptsMeenalJabde
 
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptModule-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptKAnurag2
 
OS - Ch1
OS - Ch1OS - Ch1
OS - Ch1sphs
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - IntroductionWayne Jones Jnr
 
Operating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chaptersOperating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chapterssphs
 
Process Management.ppt
Process Management.pptProcess Management.ppt
Process Management.pptJeelBhanderi4
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationMani Deepak Choudhry
 
Operating system
Operating systemOperating system
Operating systemMark Muhama
 
Process Control Block (PCB) print 4.pdf
Process Control Block  (PCB) print 4.pdfProcess Control Block  (PCB) print 4.pdf
Process Control Block (PCB) print 4.pdffentahunmuluye23
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OSC.U
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringYogesh Santhan
 
Fundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxFundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxUttara University
 
operating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsoperating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsJyoReddy9
 
OS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osOS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osTahaShahid18
 

Similar to operating system for computer engineering ch3.ppt (20)

Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Chapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System ConceptsChapter 1 Introduction to Operating System Concepts
Chapter 1 Introduction to Operating System Concepts
 
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.pptModule-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
Module-6 process managedf;jsovj;ksdv;sdkvnksdnvldknvlkdfsment.ppt
 
OS - Ch1
OS - Ch1OS - Ch1
OS - Ch1
 
Chapter 1 - Introduction
Chapter 1 - IntroductionChapter 1 - Introduction
Chapter 1 - Introduction
 
Operating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chaptersOperating systems. replace ch1 with numbers for next chapters
Operating systems. replace ch1 with numbers for next chapters
 
Process Management.ppt
Process Management.pptProcess Management.ppt
Process Management.ppt
 
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncationLM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
LM9 - OPERATIONS, SCHEDULING, Inter process xommuncation
 
Operating system
Operating systemOperating system
Operating system
 
Operating system
Operating systemOperating system
Operating system
 
Process Control Block (PCB) print 4.pdf
Process Control Block  (PCB) print 4.pdfProcess Control Block  (PCB) print 4.pdf
Process Control Block (PCB) print 4.pdf
 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OS
 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
 
Process
ProcessProcess
Process
 
OSCh4
OSCh4OSCh4
OSCh4
 
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
 
Fundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptxFundamental Operating System Concepts.pptx
Fundamental Operating System Concepts.pptx
 
operating system over view.ppt operating sysyems
operating system over view.ppt operating sysyemsoperating system over view.ppt operating sysyems
operating system over view.ppt operating sysyems
 
OS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of osOS - Chapter # 3 for the development of os
OS - Chapter # 3 for the development of os
 
Operating system
Operating systemOperating system
Operating system
 

Recently uploaded

Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)NareenAsad
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...josephjonse
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfssuser5c9d4b1
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxMustafa Ahmed
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological universityMohd Saifudeen
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfJNTUA
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.MdManikurRahman
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...IJECEIAES
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Nitin Sonavane
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...drjose256
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxMustafa Ahmed
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfMadan Karki
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfmahaffeycheryld
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 

Recently uploaded (20)

Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
"United Nations Park" Site Visit Report.
"United Nations Park" Site  Visit Report."United Nations Park" Site  Visit Report.
"United Nations Park" Site Visit Report.
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...Performance enhancement of machine learning algorithm for breast cancer diagn...
Performance enhancement of machine learning algorithm for breast cancer diagn...
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdf
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 

operating system for computer engineering ch3.ppt

  • 2. 3.1 Process Concept  Early operating systems allowed only one program to be executed at a time. This program had complete control of the system.  Current-day OS allow multiple programs to be loaded and executed concurrently with the CPU(CPUs) multiplexed among them.  Textbook uses the terms job and process almost interchangeably  Process – is a program in execution; it is more than program code (called text section).  A process includes the current activity represented by the value of:  program counter  Processor’s registers  Stack, which contains temporary data( such as function parameters, return addresses and local variables)  data section which contains global variables  Heap which is memory that is dynamically allocated during process run time.  A program by itself is not a process; it is a passive entity such as a file containing a list of instructions stored on disk (often called executable file), whereas a process is an active entity. A program becomes a process when an executable file is loaded into memory either by double-clicking the program’s icon or entering the name of the executable file on the CLI.
  • 3. 3.1 Process Concept…..  Although two processes may be associated with the same program, they are nevertheless considered two separate execution sequences. Although the text sections are equivalent, the data, heap, and stack sections vary. Example: a user may invoke many copies of a web-browser program.  The diagram below shows a process in memory
  • 4. 3.2 Process State  The state of a process is defined in part by the current activity of that process. As a process executes, it changes state  new: The process is being created  running: Instructions are being executed  waiting: The process is waiting for some event to occur(such as an I/O completion or reception of a signal)  ready: The process is waiting to be assigned to a processor  terminated: The process has finished execution  Note: only one process can be running on any processor at any instant. Many processes may be ready and waiting however.
  • 5. 3.3 Process Control Block (PCB) Each process is represented in the OS by PCB also called task control block. Information associated with each process are:  Process state: new, ready, running, waiting, halted…  Program counter(PC): indicates the address of the next instruction to be executed for this process.  CPU registers: along with PC, this state information must be saved when an interrupt occurs to allow the process be continued correctly afterward.  CPU scheduling information: includes process priority, pointers to scheduling queues and other scheduling parameters.  Memory-management information: includes the value of base and limit registers, page tables/segment tables and so on.  Accounting information: includes amount of CPU and real time used, time limits, account numbers, process numbers etc.  I/O status information: includes the list of I/O devices allocated to the process, a list of open files and so on.
  • 6. CPU Switch From Process to Process
  • 7. 3.4 Process Scheduling The objective of multiprogramming is to have some processes running at all times, to maximize CPU utilization. The objective of time sharing is to switch the CPU among processes so frequently that users can interact with each program while it is running. Scheduling Queues  Job queue – set of all processes in the system  Ready queue – list of all processes residing in main memory, ready and waiting to execute  Device queues – list of processes waiting for an I/O device  Processes migrate among the various queues
  • 8. Ready Queue And Various I/O Device Queues
  • 10. 3.5 Schedulers  Long-term scheduler (or job scheduler) – selects which processes should be brought into the memory(ready queue).  Short-term scheduler (or CPU scheduler) – selects from among the processes that are ready to execute and allocates CPU to one of them  Difference between these two schedulers lies in frequency of execution  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 (the number of processes in memory)  Processes can be described as either:  I/O-bound process – spends more time doing I/O than computations, many short CPU bursts  CPU-bound process – spends more time doing computations; few very long CPU bursts
  • 11. Addition of Medium Term Scheduling
  • 12. Context Switch  Interrupts cause the OS to change a CPU from its current task and to run a kernel routine. The system must save the state of the process currently running and load the saved state (state restore) for the new process.  Context-switch time is overhead because the system does no useful work while switching  Context-switch times are dependent on hardware support. Example: the set of registers in the system.
  • 13. 3.6 Operations on Processes 3.6.1 Process Creation  Parent process create children processes, which, in turn create other processes, forming a tree of processes  To accomplish its tasks, a process will need certain resources which it will obtain directly from OS or parent process.  Resource sharing  Parent and children share all resources  Children share subset of parent’s resources  Parent and child share no resources  Restricting a child process to a subset of the parent’s resources prevents any process from overloading the system by creating too many sub processes.  Two possibilities in terms of execution  Parent and children execute concurrently  Parent waits until children terminate  Two possibilities in terms of address space  Child duplicate of parent(it has the same program and data as the parent)  Child has a program loaded into it
  • 14. Process Creation (Cont.)  UNIX examples  fork system call creates new process  exec system call used after a fork to replace the process’ memory space with a new program
  • 15. A tree of processes on a typical Solaris
  • 16. 3.6.2 Process Termination  A process terminates when it finishes its last statement and asks the operating system to delete it (by using the exit() system call).  The process may return a status value to its parent process (via wait() system call).  Process’ resources are deallocated by operating system  Parent may terminate execution of its children processes using appropriate system call (abort) for various reasons such as :  Child has exceeded allocated resources  Task assigned to child is no longer required  If parent is exiting  Some operating system do not allow child to continue if its parent terminates – All children terminated - cascading termination
  • 17. 3.7 Cooperating Processes  Independent process cannot affect or be affected by the execution of another process(does not share data with any other process).  Cooperating process can affect or be affected by the execution of another process(shares data with other process)  Advantages of process cooperation  Information sharing: several users may need same information  Computation speed-up: enables parallel execution  Modularity  Convenience  Cooperating processes require an inter process communication (IPC) mechanism to exchange data and information. Two models of IPC are  Shared memory  Message passing
  • 18. 3.7.1 Shared Memory  Processes can exchange information by reading and writing data to a shared memory region established by the cooperating processes.  A shared memory region resides in the address space of the process creating it. The other processes that wish to communicate attach it to their address space.  Allows maximum speed and convenience of communication as it can be done at memory speeds when within a computer.  System calls are required only to establish shared memory regions and no assistance from the kernel is required to access the shared memory.  Producer-consumer problem: paradigm for cooperating processes, producer process produces information that is consumed by a consumer process. One solution is to use buffer  unbounded-buffer places no practical limit on the size of the buffer  bounded-buffer assumes that there is a fixed buffer size
  • 19. Communications Models Fig. IPC a) message passing b) shared-memory
  • 20. 3.7.2 Message Passing  Communication takes place by means of messages exchanged between the cooperating processes. Example : a chat program used on WWW  Useful for exchanging smaller amount of data  Easier to implement than shared-memory for inter computer communication  Typically implemented using system calls and thus require more time-consuming task of OS intervention.  Message-passing facility provides two operations:  send(message) – message size can be either fixed or variable  receive(message)  If P and Q wish to communicate, they need to:  establish a communication link between them  exchange messages via send/receive  Implementation of logical communication link  physical (e.g., shared memory, hardware bus)  logical (e.g., logical properties)
  • 21. Implementation Questions  How are links established?  Can a link be associated with more than two processes?  How many links can there be between every pair of communicating processes?  What is the capacity of a link?  Is the size of a message that the link can accommodate fixed or variable?  Is a link unidirectional or bi-directional?
  • 22. 3.7.2.1 Direct Communication  Processes must name each other explicitly: the send() and receive() primitives are defined as  send (P, message) – send a message to process P  receive(Q, message) – receive a message from process Q  Properties of communication link  Links are established automatically  A link is associated with exactly one pair of communicating processes  Between each pair there exists exactly one link  The link may be unidirectional, but is usually bi-directional
  • 23. 3.7.2.2 Indirect Communication  Messages are sent to and received from mailboxes (also referred to as ports)  Each mailbox has a unique id  Processes can communicate only if they share a mailbox  Primitives are defined as  send (A, message) – send a message to mailbox A  receive(A, message) – receive a message from mailbox A  Properties of communication link  Link established only if processes share a common mailbox  A link may be associated with more than two processes  Each pair of processes may share several communication links  Link may be unidirectional or bi-directional
  • 24. 3.7.2.2 Indirect Communication……..  Mailbox sharing  Suppose processes P1, P2, and P3 share mailbox A and P1, sends message to A. which process will receive the message?  Solutions depends on  Allow a link to be associated with at most two processes  Allow only one process at a time to execute a receive operation  Allow the system to select arbitrarily one receiver, not both. Sender is notified who the receiver was.  A mailbox may be owned by a process or by OS  OS must provide operations to  create a new mailbox  send and receive messages through mailbox  destroy a mailbox  When a process that owns a mailbox terminates, the mailbox disappears. A mailbox owned by OS has an existence of its own.
  • 25. 3.7.2.3 Synchronization  Message passing may be either blocking or non-blocking  Blocking is considered synchronous  Blocking send has the sender block until the message is received by process or mailbox.  Blocking receive has the receiver block until a message is available  Non-blocking is considered asynchronous  Non-blocking send has the sender send the message and continue  Non-blocking receive has the receiver receive a valid message or null
  • 26. 3.7.2.4 Buffering  Queue of messages attached to the link to temporarily store messages; implemented in one of three ways 1. Zero capacity – queue has zero length thus the link cannot have any messages waiting in it. Sender must wait for receiver. 2. Bounded capacity – queue has finite length of n messages. Sender must wait if link full 3. Unbounded capacity – potentially infinite length queue. Sender never waits.
  • 27. Client-Server Communication  Sockets  Remote Procedure Calls  Remote Method Invocation (Java)
  • 28. Sockets  A socket is defined as an endpoint for communication  Concatenation of IP address and port  The socket 161.25.19.8:1625 refers to port 1625 on host 161.25.19.8  Communication consists between a pair of sockets
  • 30. Remote Procedure Calls  Remote procedure call (RPC) abstracts procedure calls between processes on networked systems.  Stubs – client-side proxy for the actual procedure on the server.  The client-side stub locates the server and marshalls the parameters.  The server-side stub receives this message, unpacks the marshalled parameters, and peforms the procedure on the server.
  • 32. Remote Method Invocation  Remote Method Invocation (RMI) is a Java mechanism similar to RPCs.  RMI allows a Java program on one machine to invoke a method on a remote object.