Download presentation
Presentation is loading. Please wait.
Published byHubert Morton Modified over 9 years ago
1
COS 461 Fall 1997 Where We Are u so far: networking u rest of semester: distributed computing –how to use networks to do interesting things –connection to operating systems, programming languages u today –remote procedure call –naming
2
COS 461 Fall 1997 Client-Server Model: Examples u file server: stores files and accepts open/close/read/write requests u print server u DNA sequence server u chess server u Web server u directory server
3
COS 461 Fall 1997 Client-Server Programming u interaction between client and service –client sends command and arguments –server computes –server sends back reply data u abstractly, just like calling a procedure u many chances to make programming errors –data format –command codes –reply codes
4
COS 461 Fall 1997 Remote Procedure Call (RPC) u idea –make it look just like procedure call –automate the writing of data-handling and formatting code u advantages –fewer errors –faster to code and evolve interfaces –can connect to language mechanisms
5
COS 461 Fall 1997 RPC Structure client program server program client stub server stub network call return
6
COS 461 Fall 1997 Building an RPC App client code interface def’n stub generator server stub client stub compiler/ linker compiler/ linker client app server app server code
7
COS 461 Fall 1997 Interface Definition Example PROCEDURE add(IN int x, IN int y, OUT int sum); STRUCT foo { int x; boolean b; } PROCEDURE p(INOUT foo f);
8
COS 461 Fall 1997 Client Stub Example void remote_add(Server s, int* x, int* y, int* sum) { s.sendInt(AddProcedureCode); s.sendInt(*x); s.sendInt(*y); s.flush(); status = s.receiveInt(); /* check for error status */ *sum = s.receiveInt(); } void remote_p(Server s, struct foo * f) {...
9
COS 461 Fall 1997 Server Stub Example void serverLoop(Client c) { while(1) { int procedureCode = c.receiveInt(); switch(procedureCode) { case AddProcedureCode: int x = c.receiveInt(); int y = c.receiveInt(); int sum; add(*x, *y, *sum); c.sendInt(StatusOK); c.sendInt(sum); break;...
10
COS 461 Fall 1997 RPC and Threads u local procedure call: thread jumps from caller to callee u RPC: thread can’t jump u alternative: block calling thread, transfer control to thread on callee –one thread on callee: can deadlock –one thread for each client: too many threads –make threads on demand: can be slow
11
COS 461 Fall 1997 RPC Binding u How does the client find the server? –can hard-wire location –can use “name server” –hard-wire name server location u client represents “handle” to a server as a Binding object –often, Bindings can be passed between clients u a process can be both a client and a server
12
COS 461 Fall 1997 Coping with Errors in RPC u RPC isn’t quite like local procedure call –communication errors –call-by-copy, not -value or -reference u comm errors may leave client uncertain about whether the call really happened –various semantics possible: at-least-once, at- most-once, exactly-once –difference is visible, unless call is idempotent
13
COS 461 Fall 1997 RPC and Objects u RPC and object-oriented programming fit together very nicely. –encapsulation –use method calls, not direct data access u several systems put an object face on RPC –hides many of the warts of RPC u next lecture: look at one system in depth
14
COS 461 Fall 1997 Naming u What’s in a name? u naming, binding and distribution u name consistency u scaling u capabilities u examples
15
COS 461 Fall 1997 Things that are Named u people u machines u files u programs u services u variables u datatypes u mailing lists
16
COS 461 Fall 1997 What Names Do u uniquely identify something –can be placeholder for not-yet-created thing u provide information about location, function u specify membership in a group u specify a role being played by the named object u convey knowledge of a secret
17
COS 461 Fall 1997 Names and Locations u location-dependent names –convey location information –implied commitment not to move the object u local names –valid only in one place u pure names –can be located anywhere –not globally unique
18
COS 461 Fall 1997 Pure Names and Location u pure names don’t convey location; how do you find the object? u short answer: name servers u details –use hack to find a name server –name contains location of name server –hierarchical names
19
COS 461 Fall 1997 Hierarchical Names u example: /usa/edu/princeton/cs/www/courses/cs461 u advantages –globally unique –implement using hierarchy of name servers u disadvantages –must agree on who is the root –heavy load on the root
20
COS 461 Fall 1997 Relative Names u everybody runs a name server u can bind somebody else’s server to a name in yours (done by hand) –you can bind /felten to point to my server u long paths jump from server to server –/felten/mom/secretary is Felten’s Mom’s secretary u combines features of local and global naming
21
COS 461 Fall 1997 Naming and Security u the power to name is the power to control u names are “trusted” to refer to certain things –examples: “printer”, “bank” u name server(s) must be trusted u capabilities combine naming and security
22
COS 461 Fall 1997 Capabilities u A capability is a secret name for an object; knowing the capability implies permission to operate on the object –can use different capabilities for different operations u common implementation –digitally-signed statement from some authority »“the bearer may do operations X,Y,Z on object O”
23
COS 461 Fall 1997 Fun with Naming u symbolic link: one name is an alias for another u filter link: “view” of a directory that hides or modifies some names u union directory: single directory that appears to contain contents of multiple other directories u computed directories: not a directory at all, but the output of some program
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.