week 10, remote procedure call

34
Remote Proced ure Call CS-502 Fall 20 07 1 Remote Procedure Call CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts, 7 t ed!, "y Sil"ersat#, $al%in, & $agne, Modern Operating Systems, 2 nd ed!, "y 'anen"aum, and Distributed Systems: Principles & Paradigms, 2 nd ed! y 'anen"aum and )an Steen*

Upload: fransiskayusmina

Post on 07-Oct-2015

6 views

Category:

Documents


0 download

DESCRIPTION

herry

TRANSCRIPT

  • Remote Procedure CallCS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts, 7th ed., by Silbershatz, Galvin, & Gagne, Modern Operating Systems, 2nd ed., by Tanenbaum, and Distributed Systems: Principles & Paradigms, 2nd ed. By Tanenbaum and Van Steen)

    Remote Procedure Call

  • Message-oriented ProtocolsDifficult to design and implementEspecially with more sophisticated middlewareMany difficult implementation issues for each new implementationFormattingUniform representation of dataClient-server relationshipsMany still in widespread useTraditional TCP/IP and Internet protocols

    Remote Procedure Call

  • Remote Procedure Call (RPC)The most common framework for newer protocols and for middlewareUsed both by operating systems and by applicationsNFS is implemented as a set of RPCsDCOM, CORBA, Java RMI, etc., are just RPC systems ReferenceBirrell, Andrew D., and Nelson, Bruce, Implementing Remote Procedure Calls, ACM Transactions on Computer Systems, vol. 2, #1, February 1984, pp 39-59. (.pdf)

    Remote Procedure Call

  • Remote Procedure Call (RPC)Fundamental idea: Server process exports an interface of procedures or functions that can be called by client programssimilar to library API, class definitions, etc.Clients make local procedure/function calls As if directly linked with the server processUnder the covers, procedure/function call is converted into a message exchange with remote server process

    Remote Procedure Call

  • Ordinary procedure/function callcount = read(fd, buf, bytes)

    Remote Procedure Call

  • Remote Procedure CallWould like to do the same if called procedure or function is on a remote server

    Remote Procedure Call

  • Solution a pair of StubsA client-side stub is a function that looks to the client as if it were a callable servicefunctionI.e., same API as the services implementation of the functionA service-side stub looks like a caller to the serviceI.e., like a hunk of code invoking the service functionThe client program thinks its invoking the servicebut its calling into the client-side stubThe service program thinks its called by the clientbut its really called by the service-side stubThe stubs send messages to each other to make the RPC happen transparently (almost!)

    Remote Procedure Call

  • RPC StubsTanenbaum & Van Steen, Fig 4-7

    Remote Procedure Call

  • RPC Stubs SummaryClient-side stubLooks like local server functionSame interface as local functionBundles arguments into a message, sends to server-side stubWaits for reply, un-bundles resultsreturnsServer-side stubLooks like local client function to serverListens on a socket for message from client stubUn-bundles arguments to local variablesMakes a local function call to serverBundles result into reply message to client stub

    Remote Procedure Call

  • Result a very useful AbstractionThe hard work of building messages, formatting, uniform representation, etc., is buried in the stubsWhere it can be automated!Designers of client and server can concentrate on semantics of applicationPrograms behave in familiar way

    Remote Procedure Call

  • RPC IssuesHow to make the remote part of RPC invisible to the programmer?What are semantics of parameter passing?E.g., pass by reference?How to bind (locate & connect) to servers?How to handle heterogeneity?OS, language, architecture, How to make it go fast?

    Remote Procedure Call

  • RPC ModelA server defines the service interface using an interface definition language (IDL)the IDL specifies the names, parameters, and types for all client-callable server procedures

    A stub compiler reads the IDL declarations and produces two stub functions for each server functionServer-side and client-side

    Remote Procedure Call

  • RPC Model (continued)Linking:Server programmer implements the services functions and links with the server-side stubsClient programmer implements the client program and links it with client-side stubsOperation:Stubs manage all of the details of remote communication between client and server

    Remote Procedure Call

  • Marshalling ArgumentsMarshalling is the packing of function parameters into a message packetthe RPC stubs call type-specific functions to marshal or unmarshal the parameters of an RPCClient stub marshals the arguments into a messageServer stub unmarshals the arguments and uses them to invoke the service functionon return:the server stub marshals return valuesthe client stub unmarshals return values, and returns to the client program

    Remote Procedure Call

  • Issue #1 representation of dataBig endian vs. little endianSent by PentiumRecd by SPARCAfter inversion

    Remote Procedure Call

  • Representation of Data (continued)IDL must also define representation of data on networkMulti-byte integersStrings, character codesFloating point, complex, example: Suns XDR (external data representation)Each stub converts machine representation to/from network representationClients and servers must not try to cast data!

    Remote Procedure Call

  • Issue #2 Pointers and Referencesread(int fd, char* buf, int nbytes)Pointers are only valid within one address spaceCannot be interpreted by another processEven on same machine!

    Pointers and references are ubiquitous in C, C++Even in Java implementations!

    Remote Procedure Call

  • Pointers and References Restricted SemanticsOption: call by valueSending stub dereferences pointer, copies result to messageReceiving stub conjures up a new pointerOption: call by resultSending stub provides buffer, called function puts data into itReceiving stub copies data to callers buffer as specified by pointer

    Remote Procedure Call

  • Pointers and References Restricted Semantics (continued)Option: call by value-resultCallers stub copies data to message, then copies result back to client bufferServer stub keeps data in own buffer, server updates it; server sends data back in reply

    Not allowed:Call by referenceAliased arguments

    Remote Procedure Call

  • Transport of Remote Procedure CallOption TCPConnection-based, reliable transmissionUseful but heavyweight, less efficientNecessary if repeating a call produces different resultAlternative UDPIf message fails to arrive within a reasonable time, callers stub simply sends it againOkay if repeating a call produces same result

    Remote Procedure Call

  • Asynchronous RPCAnalogous to spawning a threadCaller must eventually wait for resultAnalogous to join

    Remote Procedure Call

  • Asynchronous RPC (continued)Analogous to spawning a threadCaller must eventually wait for resultAnalogous to joinOr be interrupted (software interrupt)

    Remote Procedure Call

  • RPC BindingBinding is the process of connecting the client to the serverthe server, when it starts up, exports its interfaceidentifies itself to a network name servertells RPC runtime that it is alive and ready to accept callsthe client, before issuing any calls, imports the serverRPC runtime uses the name server to find the location of the server and establish a connectionThe import and export operations are explicit in the server and client programs

    Remote Procedure Call

  • Remote Procedure Call is used Between processes on different machinesE.g., client-server model

    Between processes on the same machineMore structured than simple message passing

    Between subsystems of an operating systemWindows XP (called Local Procedure Call)

    Remote Procedure Call

  • Questions?

    Remote Procedure Call

  • Practical RPC SystemsDCE (Distributed Computing Environment)Open Software FoundationBasis for Microsoft DCOMTanenbaum & Van Steen, 4.2.4Suns ONC (Open Network Computing)Very similar to DCEWidely usedrpcgenhttp://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-Q0R5B-TET1_html/TITLE.html

    Remote Procedure Call

  • Practical RPC Systems (continued)Java RMI (Remote Method Invocation)java.rmi standard packageJava-oriented approach objects and methodsCORBA (Common Object Request Broker Architecture) Standard, multi-language, multi-platform middlewareObject-orientedHeavyweight

    Remote Procedure Call

  • Implementation Model for DCE

    Remote Procedure Call

  • Implementation Model for ONCprogram & version #program & version #rpcgenXDR

    Remote Procedure Call

  • Validating a Remote ServicePurposeAvoid binding to wrong service or wrong versionDCEGlobally unique IDGenerated in template of IDL fileSun ONCProgram numbers registered with SunVersion # and procedure # administered locally

    Remote Procedure Call

  • RPC Binding Sun ONCService registers with portmapper service on server OSProgram # and version #Optional static port #ClientMust know host name or IP addressclnt_create(host, prog, vers, proto)I.e., RPC to portmapper of host requesting to bind to prog, vers using protocol proto (tcp or udp)(Additional functions for authentication, etc.)Invokes remote functions by name

    Remote Procedure Call

  • Sun ONC (continued)#include Header file for client and serverrpcgenThe stub compilerCompiles interface.xProduces .h files for client and service; also stubsSee alsorpcinfoRPC Programming Guide

    Remote Procedure Call

  • Note on XDR(the Interface Definition Language for ONC)Much like C header fileExceptionsstring type maps to char *bool type maps to bool_t

    Remote Procedure Call

  • Sun ONCOnline tutorialhttp://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/HTML/AA-Q0R5B-TET1_html/TITLE.htmlCode sampleshttp://web.cs.wpi.edu/~rek/DCS/D04/SunRPC.htmlhttp://web.cs.wpi.edu/~goos/Teach/cs4513-d05/http://web.cs.wpi.edu/~cs4513/b05/week4-sunrpc.pdf Any other resources you can find

    Remote Procedure Call

  • Questions?

    Remote Procedure Call

    Assumptions:Graduate levelOperating SystemsMaking Choices about operation systems

    Why a micro-century? just about enough time for one concept