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

PPT
OSLec 4& 5(Processesinoperatingsystem).ppt
ssusere16bd9
 
PPTX
Operating Systems - Process Scheduling Management
Dr. Chandrakant Divate
 
PPTX
381CCS_CHAPTER3_UPDATED king Khalid .pptx
HakimAlHuribi
 
PPT
Ch2_Processes_and_process_management_1.ppt
Mohammad Almuiet
 
PDF
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
PPT
LEC_3.ppt jef,fdds,fn,befhj efbhjfrgeukevbhwj
lipof22824
 
PDF
Chapter 3.pdf
HikaTariku
 
DOCX
BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...
Nur Atiqah Mohd Rosli
 
OSLec 4& 5(Processesinoperatingsystem).ppt
ssusere16bd9
 
Operating Systems - Process Scheduling Management
Dr. Chandrakant Divate
 
381CCS_CHAPTER3_UPDATED king Khalid .pptx
HakimAlHuribi
 
Ch2_Processes_and_process_management_1.ppt
Mohammad Almuiet
 
Lecture 3_Processes in Operating Systems.pdf
jamesLau66
 
LEC_3.ppt jef,fdds,fn,befhj efbhjfrgeukevbhwj
lipof22824
 
Chapter 3.pdf
HikaTariku
 
BITS 1213 - OPERATING SYSTEM (PROCESS,THREAD,SYMMETRIC MULTIPROCESSOR,MICROKE...
Nur Atiqah Mohd Rosli
 

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

DOCX
CHAPTER READING TASK OPERATING SYSTEM
Nur Atiqah Mohd Rosli
 
PPTX
Operating system - Process and its concepts
Karan Thakkar
 
PPT
Ch03 processes
Nazir Ahmed
 
PPTX
Processes
RaviRaj339
 
PPT
UNIT I Process management main concept.ppt
vaibavmugesh
 
PPTX
2Chapter Two- Process Management(2) (1).pptx
jamsibro140
 
PDF
Ch3 processes
Welly Dian Astika
 
PPTX
3. Process Concept in operating system.pptx
viceprincipalbfc
 
PPTX
Operating Systems Process Management.pptx
Sivakumar M
 
PDF
process.pdfzljwiyrouyaeutoaetodtusiokklhh
abhinandpk2405
 
PPTX
Operating system Chapter 3 Part-1 process and threads.pptx
fikadumeuedu
 
PPT
OS_Unit_II_Ch3 Process and CPU Scheduling
SDivya19
 
PPT
Lecture5
Ali Shah
 
PPTX
UNIT I-Processes.pptx
GaneshKumar537286
 
PPTX
Handling Large Data Volumes in Salesforce with Apex
MuhammadMahad31
 
PPTX
operating system module 2 presentation notes
ksamjish
 
PDF
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
PPT
Process Management.ppt
JeelBhanderi4
 
PDF
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
morganjohn3
 
CHAPTER READING TASK OPERATING SYSTEM
Nur Atiqah Mohd Rosli
 
Operating system - Process and its concepts
Karan Thakkar
 
Ch03 processes
Nazir Ahmed
 
Processes
RaviRaj339
 
UNIT I Process management main concept.ppt
vaibavmugesh
 
2Chapter Two- Process Management(2) (1).pptx
jamsibro140
 
Ch3 processes
Welly Dian Astika
 
3. Process Concept in operating system.pptx
viceprincipalbfc
 
Operating Systems Process Management.pptx
Sivakumar M
 
process.pdfzljwiyrouyaeutoaetodtusiokklhh
abhinandpk2405
 
Operating system Chapter 3 Part-1 process and threads.pptx
fikadumeuedu
 
OS_Unit_II_Ch3 Process and CPU Scheduling
SDivya19
 
Lecture5
Ali Shah
 
UNIT I-Processes.pptx
GaneshKumar537286
 
Handling Large Data Volumes in Salesforce with Apex
MuhammadMahad31
 
operating system module 2 presentation notes
ksamjish
 
CS6401 OPERATING SYSTEMS Unit 2
Kathirvel Ayyaswamy
 
Process Management.ppt
JeelBhanderi4
 
Module 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModule 2 - PPT.pdfModul...
morganjohn3
 
Ad

Recently uploaded (20)

PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
JUAL EFIX C5 IMU GNSS GEODETIC PERFECT BASE OR ROVER
Budi Minds
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Software Testing Tools - names and explanation
shruti533256
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PPTX
easa module 3 funtamental electronics.pptx
tryanothert7
 
PDF
Introduction to Data Science: data science process
ShivarkarSandip
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
The Asian School
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Inventory management chapter in automation and robotics.
atisht0104
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
JUAL EFIX C5 IMU GNSS GEODETIC PERFECT BASE OR ROVER
Budi Minds
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Software Testing Tools - names and explanation
shruti533256
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
easa module 3 funtamental electronics.pptx
tryanothert7
 
Introduction to Data Science: data science process
ShivarkarSandip
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Ppt for engineering students application on field effect
lakshmi.ec
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
Ad

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.