IPC and RPC.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

©2009 Operačné systémy Procesy. 3.2 ©2009 Operačné systémy Process in Memory.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
Chapter 3: Processes.
Outcomes What is RPC? The difference between conventional procedure call and RPC? Understand the function of client and server stubs How many steps could.
1/30/2004CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 3: Processes. Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
02/01/2010CSCI 315 Operating Systems Design1 Interprocess Communication Notice: The slides for this lecture have been largely based on those accompanying.
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Interprocess Communication. Process Concepts Last class.
Inter-Process Communication Mechanisms CSE331 Operating Systems Design.
Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Problems with Send and Receive Low level –programmer is engaged in I/O –server often not modular –takes 2 calls to get what you want (send, followed by.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 3 Operating Systems.
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765.
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
InterProcess Communication. Interprocess Communication Processes within a system may be independent or cooperating Cooperating process can affect or be.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
RPC Model, Stubs and Skeletons Divya Nampalli
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process Termination Process executes last statement and asks the operating.
Chapter 3: Processes.
Chapter 3: Process Concept
Prof. Leonardo Mostarda University of Camerino
Operating System Concepts
Chapter 4: Processes Process Concept Process Scheduling
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Last Class: RPCs and RMI
Threads and Cooperation
Chapter 3: Processes.
Applied Operating System Concepts
CMSC621: Advanced Operating Systems Advanced Operating Systems
Communication Chapter 2.
Chapter 4: Processes Process Concept Process Scheduling
Lecture 2: Processes Part 1
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Threads and Data Sharing
OPERATING SYSTEMS PROCESSES
MPI-Message Passing Interface
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Sarah Diesburg Operating Systems COP 4610
Chapter 3: Processes.
Chapter 3: Processes.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Chapter 3: Processes.
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
Process Synchronization
Remote Procedure Call Hank Levy 1.
Chapter 3: Processes.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 7: RPC (exercises/questions)
Remote Procedure Call Hank Levy 1.
Processes August 10, 2019 OS:Processes.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

IPC and RPC

Interprocess Communication (IPC) Processes within a system may be independent or cooperating Cooperating process can affect or be affected by other processes, including sharing data Reasons for cooperating processes: Information sharing Computation speedup Modularity Convenience Cooperating processes need interprocess communication (IPC) Two models of IPC Shared memory Message passing

Communication Models

Shared memory Processes Threads Advantages Disadvantages Each process has private address space Explicitly set up shared memory segment within each address space Threads Always share address space (use heap for shared data) Advantages Fast and easy to share data Disadvantages Must synchronize data accesses; error prone

Message Passing Message passing most commonly used between processes Explicitly pass data between sender and receiver Example: Unix pipes, Windows LPC Advantages: Makes sharing explicit Improves modularity (narrow interface) Does not require trust between sender and receiver Disadvantages: Performance overhead to copy messages Issues: How to name source and destination? One process, set of processes, or mailbox (port) Does sending process wait (I.e., block) for receiver? Blocking: Slows down sender Non-blocking: Requires buffering between sender and receiver

Message Passing Details Mechanism for processes to communicate and to synchronize their actions Message system – processes communicate with each other without resorting to shared variables If P and Q wish to communicate, they need to: establish a communication link between them exchange messages via send/receive Implementation of communication link physical (e.g., shared memory, hardware bus) logical (e.g., logical properties)

Producer-Consumer Problem Paradigm for cooperating processes producer process produces data Writes data into a shared buffer consumer process consumes data Reads data from shared buffer Makes synchronized access easier unbounded-buffer places no practical limit on the size of the buffer bounded-buffer assumes that there is a fixed buffer size

Example: Unix Pipes int pipedes[2], pid; // pipedes[0] = read, pipedes[1] = write pipe(pipedes); pid = fork(); if (pid == 0) { // child write(pipedes[1], ”hello”, sizeof(“hello”); } else { //parent read(pipedes[0], buffer, 100); } Access to pipes is through file system calls; can be used most places a file can (Q: where not?) Kernel implements a bounded buffer; reader blocks if full and writer blocks if empty

Message Passing Libraries (MPI) A message-passing library specifications for parallel computers, clusters, and heterogeneous networks Extended message-passing model Communication modes Standard, synchronous, buffered, and ready. Designed for parallel applications and tailored to transient communications Provides access to advanced parallel hardware It assumes that serious failures are fatal and do not require automatic recovery For example, process crashes or network disconnect

Group and Context Communicator MPI assumes communication takes place with a group of processes – (groupID, procID) Use in lieu of a transport-level address MPI ties the concepts of process group and communication context into a communicator Communicator Group Context

MPI Abstractions A process group is high-level abstraction, visible to users A context is a system-defined object that uniquely identifies a communicator Mechanism to isolate messages in distinct libraries and the user programs from one another A message sent in one context can't be received in other contexts. The communication context is low-level abstraction, not visible to users A communicator is a data object that specializes the scope of a communication. MPI_COMM_WORLD is an initial communicator, which is predefined and consists of all the processes running when program execution begins

MPI Communication Semantics Point-to-point communication is the basic concept of MPI standard and fundamental for send and receive operations for typed data with associated message tag. Using the point-to point communication, messages can be passed to another process with explicit message tag and implicit communication context. MPI is made thread-safe by not using global state.

MPI Communication Primitives Meaning MPI_bsend Append outgoing message to a local send buffer MPI_send Send a message and wait until copied to local or remote buffer MPI_ssend Send a message and wait until receipt starts MPI_sendrecv Send a message and wait for reply MPI_isend Pass reference to outgoing message, and continue MPI_issend Pass reference to outgoing message, and wait until receipt starts MPI_recv Receive a message; block if there are none MPI_irecv Check if there is an incoming message, but do not block

MPI Send/Recv MPI_Send(void * data, int count, MPI_Datatype datatype, int destination, // Rank (address) of destination int tag, // Message ID MPI_Comm communicator); // Set of processes in application MPI_Recv(void * data, int source, // Rank (address) of sender int tag, // Message ID MPI_Comm communicator, // Set of processes in application MPI_Status * status);

Basic Operation, Stubs, Parameter Passing REMOTE PROCEDURE CALL Basic Operation, Stubs, Parameter Passing

Remote Procedure Call Explicit message passing has been typically used in early distributed systems The paradigm does not achieve access transparency send() and receive() primitives do not conceal communication from the communicating entities Alternative method to message passing: Have programs call procedures on other machines Simple and elegant in theory Ugly to implement in practice

Procedure Call – Basic Operation Conventional procedure call: count = read(fd, buf, nbytes); fd = file descriptor, handle buf = an array of characters nbyte = number of bytes to be read The execution of a procedure call made from the main program requires the following steps: Caller sets up function params: on stack and in registers The read() transfers control back to caller with return value

Conventional Procedure Call Parameter passing in a local procedure call (stack based) Stack before the call to read Stack while called procedure is active

Which Mechanism to Use in RPC? Parameter Passing Call-by-Value – To the called procedure a value is just an initialized local variable Call-by-Reference – The reference parameter is a pointer to a variable, rather than the value of the variable The called procedure modifies the variable in the calling procedure Call-by-Copy/Restore – The variable is copied onto the stack by the caller and copied back after the call, overwriting the caller’s original value Not often used in computer languages Which Mechanism to Use in RPC?

Remote Procedure Call Principle of RPC between a client and server program.

RPC Design Issue Make RPC look like LPC, as much as possible Transparency – Local procedure should not be aware that the called procedure is executing remotely RPC achieves its transparency in a similar way as LPC by invoking a library function call The execution of the RPC uses the concept of a stub A client stub, at the calling procedure A server stub, at the called procedure Communication between the stubs is achieved through message passing, transparently from the local procedure

RPC Information Flow Client Stub Pack Parameters Call Send Client (Caller) Packet Handler Client Mbox Return Receive Unpack Results Network Network Client Server Pack Results Server Mbox Return Server (Callee) Server Stub Unpack Parameters Send Packet Handler Call Receive

RPC COMPILATION Interface Definition IDL Compiler Client Stub Header File Server Stub

RPC COMPILATION Interface Definition IDL Compiler Client Stub Header File Server Stub Server Code Language Compiler Server Application

RPC COMPILATION Interface Definition IDL Compiler Client Code Client Stub Header File Server Stub Server Code Language Compiler Language Compiler Server Application Server Application

RPC Steps – Example The steps involved in a doing a remote computation through RPC.

RPC Details Equivalence with regular procedure call Parameters – Request Message Result – Reply message Name of Procedure – Passed in request message Return Address – client return mail box Where do stubs come from? Compiler generates stubs Input: interface definitions in an “interface definition language (IDL)” Contains, among other things, types of arguments/return Output: stub code in the appropriate source language Client code to pack and send message, wait for result, unpack result and return to caller Server Code to unpack message, call procedure, pack and send back results

RPC Implementation Issues Cross-platform issues What if client/server machines are different architectures or in different languages? How does client know where to send call request? Biding process – Need to translate name of remote service into network endpoint: Server network address, port number, possibly other information How to pass complex structures, pointers, big arrays? Handling these structure could be very costly, and perhaps impractical to pass as arguments Should there be limitation on size and types of RPC arguments?

Writing a Client and a Server The steps in writing a client and a server in DCE RPC

Writing a Client and a Server Three files output by the IDL compiler: A header file (e.g., interface.h, in C terms). The client stub. The server stub.

Binding a Client to a Server Registration of a server makes it possible for a client to locate the server and bind to it. Server location is done in two steps: Locate the server’s machine. Locate the server on that machine.

Binding a Client to a Server Client-to-server binding in DCE