Chapter2 Communication
Chapter2 Communication
PROCESS.......................................................................................................................................................................... 1
INTERPROCESS COMMUNICATION..................................................................................................................................1
Synchronous and asynchronous communication............................................................................................................2
Remote invocation (middle layer)...................................................................................................................................2
RPC vs RMI...................................................................................................................................................................... 3
Call By Value:...................................................................................................................................................................3
Call by Reference:............................................................................................................................................................3
Call by Copy/Restore.......................................................................................................................................................3
RPC Steps:.......................................................................................................................................................................4
Message vs Stream oriented communication UDP vs TCP..............................................................................................4
Message passing:............................................................................................................................................................4
Message passing vs RPC..................................................................................................................................................5
MULTICAST...................................................................................................................................................................... 5
PROCESS
• Instance
• A concrete occurrence of any object in object- oriented programming (OOP);
• Existing during the runtime of a computer program.
• Formally, instance = object (with a particular value).
• Process
• The instance being executed by one or many threads;
• Contains the program code and its activity;
• May consist of many concurrently executing threads;
• Several processes may be associated with the same program.
• Multitasking
• Multiple processes to share processors (CPUs) and other system resources.
• Each CPU (core) executes a single task at a time.
• Each processor switches between tasks without waiting for finishing each task.
• Switches occur when
• Tasks perform input/output operations,
• Task indicates that it can be switched, or
• Hardware interrupts.
• Time-sharing
• A multitasking method to allow high responsiveness for interactive user applications.
• Context switches are performed rapidly
• Like multiple processes are being executed simultaneously on the same processor (concurrency).
INTERPROCESS COMMUNICATION
• Process communication
• Processes in an operation system
• Processes in different operation systems
• Exchanging messages across the computer network;
• The processes reside in the application layer.
• The Interface Between the Process and the Computer Network
Processes send and receive messages through a software interface called a socket;
Socket: Application Programming Interface (API) between the application and the
network
Characteristics:
• Endpoint for inter-process communication
• Message transmission between sockets
• A socket is associated with either UDP or TCP
• Sockets are bound to ports
• One process can use many ports
• Processes don’t share sockets (unless for IP multicast)
Socket= Internet address + port number
• Only one receiver but many senders per port
• Advantage: several points of entry to process
• Disadvantage: location dependence
The only control that the application developer has on the transport- layer side:
• The choice of transport protocol;
• A few transport-layer parameters such as maximum
buffer and maximum segment sizes
Addressing Processes:
• IP address
• Port number
Two message communication operations: send & receive (both can be blocking
or non-blocking). Receive is usually blocking– destination process blocked until
message arrives– most common case
• Whenever a send is issued the sending process is blocked until the corresponding receive is issued.
• Problems– failure and indefinite delay causes indefinite blocking (use timeout)– multicasting/broadcasting
not supported– implementation more complex
Asynchronous:
• Send is nonblocking
• Receive: Blocking or Non-blocking: the receiving process proceeds with its program after issuing a receive
operation.
• Problems– buffer overflow– error reporting (difficult to match error with message)
• Client programs to call procedures transparently in server programs running in separate processes
and generally in different computers from the client.
• An object living in one process to invoke the methods of an object living in another process.
RPC vs RMI
Challenges:
Call By Value:
• Values of actual parameters are copied to function’s formal parameters;
• Any changes made inside functions are not reflected in actual parameters of caller.
Call by Reference:
• Both the actual and formal parameters refer to same locations,
• Any changes made inside the function are actually reflected in actual parameters of caller.
Call by Copy/Restore
• A special case of call-by-reference
• The final result on the referenced values will not be saved until the end of the function.
• The decision of which parameter passing mechanism to use is normally made by the language
designers and is a fixed property of the language.
RPC Steps:
• The client procedure calls the client stub in the normal way.
• The client stub builds a message and calls the local operating
system.
• The server stub unpacks the parameters and calls the server.
• The server does the work and returns the result to the stub.
Message-oriented communication
Message passing:
A technique for invoking behavior (i.e., running a program)
on a computer.
MULTICAST
Question Bank