1 / 15

CPS110: More Networks

CPS110: More Networks. Landon Cox March 27, 2008. Network abstractions. We’ve been using send/receive Client sends a request to the server Server receives request Server sends response to client What else in CS is this interaction like? Calling a function. Remote procedure call (RPC).

colt-reid
Download Presentation

CPS110: More Networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPS110: More Networks Landon Cox March 27, 2008

  2. Network abstractions • We’ve been using send/receive • Client sends a request to the server • Server receives request • Server sends response to client • What else in CS is this interaction like? • Calling a function

  3. Remote procedure call (RPC) • RPC makes request/response look local • Provide a function call abstraction • RPC isn’t a really a function call • In a normal call, the PC jumps to the function • Function then jumps back to caller • This is similar to request/response though • Stream of control goes from client to server • And then returns back to the client

  4. RPC stub functions • Key to making RPC work • Stub functions

  5. RPC stub functions call send Client stub recv return send return Server stub call recv

  6. RPC stub functions • Client stub 1) Builds request message with server function name and parameters 2) Sends request message to server stub • (transfer control to server stub) 8) Receives response message from server stub 9) Returns response value to client • Server stub 3) Receives request message 4) Calls the right server function with the specified parameters 5) Waits for the server function to return 6) Builds a response message with the return value 7) Sends response message to client stub

  7. RPC example • Client calls produce(5) Client stub: Server stub: // must be named produce! int produce (int n) { int status; send (sock, &n, sizeof(n)); recv (sock, &status, sizeof(status)); return status; } // could be named anything void produce_stub () { int n; int status; recv (sock, &n, sizeof(n)); // produce func on server! status = produce (n); send (sock, &status, sizeof(status)); } Server stub code can be generated automatically (C/C++: rpcgen, Java: rmic) What info do you need to generate the stubs? Input parameter types and the return value type.

  8. Java RMI example • Remote calculator program

  9. Problems with RPC • How is RPC different from local function calls? • Hard to pass pointers (and global variables) • What happens if server dereferences a passed-in pointer? • Pointer will access server’s memory (not client’s) • How do we solve this? • Send all data reachable from pointer to the server • Change the pointers on the server to point to the copy • Copy data back when server function returns

  10. Example RPC with pointers • On client: int a[100]; • Want to send “a” (a pointer to an array) • Copy entire array to server • Have server’s pointer point to copy of a • Copy array back to client on return • What if a is more complicated? A linked list? • Have to marshal the transitive closure of pointer

  11. Problems with RPC • Data may be represented differently • Machines have different “endianness” • Byte 0 may be least or most significant • Must agree on standard network representation • RPC has different failure modes • Server or client can fail during a call • In local case, client and server fail simultaneously

  12. Finishing RPC • Where have you used RPC in CPS 110? • Project 2 infrastructure • C library interface to system calls is similar • Makes something look like a function call

  13. Structuring a concurrent system • Talked about two ways to build a system

  14. Alternative structure • Can also give cooperating threads an address space • Each thread is basically a separate process • Use messages instead of shared data to communicate • Why would you want to do this? • Protection • Each module runs in its own address space • Reasoning behind micro-kernels • Each service runs as a separate process • Mach from CMU (influenced parts Mac OS X) • Vista’s handling of device drivers

  15. Course administration • Project 2 scores (out of 89) • 88, 86, 86, 86, 86, 84, 84, 84, 84, 71, 66, 50 • Great! • Project 3 out next week (I hope) • Questions?

More Related