RPC Model, Stubs and Skeletons Divya Nampalli 14450 25.

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

1 Communication in Distributed Systems REKs adaptation of Tanenbaums Distributed Systems Chapter 2.
CSE 486/586 Distributed Systems Remote Procedure Call
RPC Robert Grimm New York University Remote Procedure Calls.
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
Communication Dr. Ying Lu CSCE455/855 Distributed Operating Systems.
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Computing Systems 15, 2015 Next up Client-server model RPC Mutual exclusion.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
Implementing Remote Procedure Calls Andrew Birrell and Bruce Nelson Presented by Kai Cong.
Remote Method Invocation
L-7 RPC 1. Last Lecture Important Lessons - Naming Naming is a powerful tool in system design  A layer of indirection can solve many problems Name+context.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
Implementing Remote Procedure Calls Authors: Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presenter: Jim Santmyer Thanks to:
Jan 28, 2003CS475: Internetworking with UNIX TCP/IP1 XDR, RPC, NFS Internetworking with UNIX TCP/IP Winter
Outcomes What is RPC? The difference between conventional procedure call and RPC? Understand the function of client and server stubs How many steps could.
Communication in Distributed Systems –Part 2
Client-Server Communication Sockets Remote Procedure Calls Remote Method Invocation (Java)
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586 CSE 486/586 Distributed Systems Remote Procedure Call Steve Ko Computer Sciences and Engineering University at Buffalo.
1 Chapter 2. Communication. STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered Protocol But some other protocols.
Communication Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Introduction to Distributed Systems Slides for CSCI 3171 Lectures E. W. Grundke.
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.
Politecnico di Milano © 2001 William Fornaciari Operating Systems R P C Remote Procedure Call Lecturer: William Fornaciari Politecnico di Milano
Java Remote Method Invocation RMI. Idea If objects communicate with each other on one JVM why not do the same on several JVM’s? If objects communicate.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Page 1 Remote Procedure Calls Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
1 Developing Application in Distributed Computing Environment (DCE)
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765.
1 Conventional Procedure Call read(fd,buf,nbytes) a)Parameter passing in a local procedure call: the stack before the call to read b)The stack while the.
Remote Procedure Call RPC
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Computer Science Lecture 3, page 1 CS677: Distributed OS Last Class: Communication in Distributed Systems Structured or unstructured? Addressing? Blocking/non-blocking?
1 Chapter 2. Communication. STEMPusan National University STEM-PNU 2 Layered Protocol TCP/IP : de facto standard Our Major Concern Not always 7-layered.
Implementing Remote Procedure Call Landon Cox February 12, 2016.
Computer Science Lecture 4, page 1 CS677: Distributed OS Last Class: RPCs RPCs make distributed computations look like local computations Issues: –Parameter.
Lecture 5: RPC (exercises/questions). 26-Jun-16COMP28112 Lecture 52 First Six Steps of RPC TvS: Figure 4-7.
Object Interaction: RMI and RPC 1. Overview 2 Distributed applications programming - distributed objects model - RMI, invocation semantics - RPC Products.
Prof. Leonardo Mostarda University of Camerino
CSE 486/586 Distributed Systems Remote Procedure Call
Remote Method Invocation
IPC and RPC.
CMSC621: Advanced Operating Systems Advanced Operating Systems
Communication Chapter 2.
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
DISTRIBUTED COMPUTING
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Sarah Diesburg Operating Systems COP 4610
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
Lecture 6: RPC (exercises/questions)
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 6: RPC (exercises/questions)
Lecture 7: RPC (exercises/questions)
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

RPC Model, Stubs and Skeletons Divya Nampalli

l Assume that you are developing a client-server application: n How to let the two processes (client and server) located on two machines communicate with each other? u Socket programming: using functions like connect(sd, (struct sockaddr *)&sin, sizeof(sin)), write(sd, buf, strlen(buf)) etc. Client-Server Communication

Remote Procedure Calls (RPC) Avoid explicit message exchange between processes Basic idea is to allow a process on a machine to call procedures on a remote machine –Make a remote procedure possibly look like a local one

How are parameters passed in a local procedure call –E.g., #include sys/types.h #include unistd.h... char buf[20]; size_t nbytes; ssize_t bytes_read; int fd;... nbytes = sizeof(buf); bytes_read = read(fd, buf, nbytes);... Conventional Procedure Call

Figure 4-5. (a) Parameter passing in a local procedure call: the stack before the call to read. (b) The stack while the called procedure is active.

Remote Procedure Calls (RPC) How are parameter passed in a remote procedure call, while making it look like a local procedure call?

Remote Procedure Calls (RPC) Suited for Client-Server structure. Combines aspects of monitors and synchronous message passing: ∗ Module (remote object) exports operations, invoked with call. ∗ call blocks (delays caller) until serviced. call causes a new thread to be created on remote (server). Client-server synchronization and communication is implicit.

Terminology / Notation Server module: operations, (shared) variables, local procedures and threads for servicing remote procedure calls. Interface (specification): describes the operations, parameter types and return types. Server process: thread created by call to service an operation. Background process: threads running in a module that aren’t created in response to call.

Lookup and registration How does the client find the server? Often server registers (binds) with a naming service (registry). Client obtains information (lookup) about server from this server. This changes the question to: How does the client find the registry?

Synchronization Synchronization within a module (server). Two approaches: 1.Assume mutual exclusion in server (only one server process/background process executing at a time). ∗ Similar to monitors. ∗ Still need conditional synchronization. 2. Program it explicitly (i.e., using semaphores, monitors etc.)

Client and Server Stubs Principle of RPC between a client and server program.

Steps of a Remote Procedure Call 1.Client procedure calls client stub in normal way 2.Client stub builds message, calls local OS 3.Client's OS sends message to remote OS 4.Remote OS gives message to server stub 5.Server stub unpacks parameters, calls server 6.Server does work, returns result to the stub 7.Server stub packs it in message, calls local OS 8.Server's OS sends message to client's OS 9.Client's OS gives message to client stub 10.Stub unpacks result, returns to client

Skeletons and Stubs

1.‘Stub’ objects implement the same interface as the server objects. (Proxy pattern) 2. (0), (5) Client threads call a stub local to their JVM instance. 3. (1), (4) Stub messages (TCP/IP) to Skeleton object in remote JVM & waits for reply. 4. (2), (3) Skeleton creates a new server thread which calls the server. 5. Stub and skeleton classes are synthesized by a RMI Compiler (rmic).

Passing Value Parameters (1) Steps involved in doing remote computation through RPC 2-8

Passing reference parameters –What is Call By Value and Call By Refernce? –Example: call foo(int, int * ) or read(fd, buf, nbytes) –Call by copy/restore –The dreaded “ pointer problem ” Linked list Complex graph a b a’ b’ foo(a, &b ) Call foo(a, &b’ ) Copy value a and contents of loc b into a’ and loc b’ Return Copy contents of loc b’ into b Machine A Machine B

Marshalling Values must cross the network Machine formats differ –Integer byte order Little-endian or big-endian –Floating point format IEEE 754 or not Marshalling  transferring data structure used in remote procedure call from one address space to another.

RPC: The basic mechanism Client routines Client stub RPC runtime Network routines Server routines Server stub RPC runtime Network routines Process kernel Process kernel Client process Server process 1.Client calls a local procedure on the client stub 2.The client stub acts as a proxy and marshalls the call and the args. 3.The client stub send this to the remote system (via TCP/UDP) 4.The server stub unmarshalls the call and args from the client 5.The server stub calls the actual procedure on the server 6.The server stub marshalls the reply and sends it back to the client

Example1: A Time Server Interface struct time { int seconds; int minutes; int hours; int day; int month; int year; char timezone[4]; } int gettime(t); struct time *t; int settime(t); struct time *t;

Example1: Client Stub for Settime int settime(t); struct time *t; { char *p, message[32]; int stat; p = message; p = put_int(p, SETTIME); p = put_int(p, t->seconds); p = put_int(p, t->minutes); p = put_int(p, t->hours); p = put_int(p, t->day); p = put_int(p, t->month); p = put_int(p, t->year); p = put_string(p, t->timezone, 4); stat = do_operation(“time_server”, message, 32); if(stat == SUCCESS) get_int(message, &stat); return(stat); }

Example1: Server Stub (1) void main_loop() { char *p, message[32]; int len, op_code; struct time t; for(;;) { len = receive_request(message, 32); if(len < 4) { /* error handling code */ } p = message; p = get_int(p, op_code); switch(op_code) { case SETTIME: if (len < 32) { /* error handling code */ } p = get_int(p, &t.seconds); p = get_int(p, &t.minutes); p = get_int(p, &t.hours); p = get_int(p, &t.day); p = get_int(p, &t.month); p = get_int(p, &t.year); p = get_string(p, &t.timezone, 4); len = settime(&t); put_int(message, len); len = 4; break; case GETTIME: /* code for unmarshalling and calling gettime */ } send_reply(message, len); }

LPC v.s. RPC Global variables Client and server fail independently –RPC: requires code to deal with server crashes

When Things Go Wrong Semantics of remote procedure calls –Local procedure call: exactly once How many times a remote procedure call may be called? A remote procedure call may be called: –0 time: server crashed or server process died before executing server code –1 time: everything worked well –1 or more: due to excess latency or lost reply from server, client retransmitted Exactly once may be difficult to achieve with RPC

Thanks...