OS Lecture3
OS Lecture3
PROCESSES
Instructor: Dr.Fouzia Idrees
Interprocess Communication
Shared memory
In the shared-memory model, a region of memory that is shared
by cooperating processes is established. Processes can then
exchange information by reading and writing data to the share
region.
Other processes that wish to communicate using this shared-
memory segment must attach it to their address space.
Processes are also responsible for ensuring that they are not
writing to the same location simultaneously.
To understand the concept of cooperating processes lets
consider a producer-consumer problem.
The producer process produces information that is
consumed by a consumer process. For example, a
compiler may produce assembly code that is
consumed by an assembler. The assembler, in turn,
may produce object modules/code that are consumed
by the loader.
A web server produces (that is, provides) HTML files
and images, which are consumed (that is, read) by the
client web browser requesting the resource.
Producer-Consumer Problem
Sockets
Pipes
Sockets
A socket is defined as an endpoint for
communication
A pair of processes communicating over a network
employs a pair of sockets—one for each process.
sockets use a client–server architecture.
A socket is identified by an IP address concatenated
with a port number
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
An RPC is initiated by the client, which sends a request
message to a known remote server to execute a specified
procedure with supplied parameters.
The remote server sends a response to the client, and the
application continues its process. While the server is
processing the call, the client is blocked (it waits until the
server has finished processing before resuming execution),
unless the client sends an asynchronous request to the server.
Stubs – client-side proxy for the actual procedure on
the server
Issues
Is communication unidirectional or bidirectional?
In the case of two-way communication, is it half or full-duplex?
Must there exist a relationship (i.e. parent-child) between the
communicating processes?
Can the pipes be used over a network?
Ordinary Pipes
Ordinary Pipes allow communication in standard producer-
consumer style
Consumer reads from the other end (the read-end of the pipe)
Communication is bidirectional