How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

Similar documents
Lightweight RPC. Robert Grimm New York University

CS533 Concepts of Operating Systems. Jonathan Walpole

Lightweight Remote Procedure Call. Brian N. Bershad, Thomas E. Anderson, Edward D. Lazowska, and Henry M. Levy Presented by Alana Sweat

Lightweight Remote Procedure Call

Remote Procedure Call

CHAPTER - 4 REMOTE COMMUNICATION

Remote Procedure Call (RPC) and Transparency

CSci Introduction to Distributed Systems. Communication: RPC

RPC. Remote Procedure Calls. Robert Grimm New York University

Last Class: RPCs. Today:

Network File System (NFS)

Network File System (NFS)

Network File System (NFS)

Distributed Systems 8. Remote Procedure Calls

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Lecture 15: Network File Systems

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

Operating System Support

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

Filesystems Lecture 13

A Report on RMI and RPC Submitted by Sudharshan Reddy B

CS454/654 Midterm Exam Fall 2004

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

Remote Procedure Calls

Distributed File Systems. CS 537 Lecture 15. Distributed File Systems. Transfer Model. Naming transparency 3/27/09

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

Lecture 5: Object Interaction: RMI and RPC

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Appendix 4-B. Case study of the Network File System (NFS)

NFS: Naming indirection, abstraction. Abstraction, abstraction, abstraction! Network File Systems: Naming, cache control, consistency

a. Under overload, whole network collapsed iii. How do you make an efficient high-level communication mechanism? 1. Similar to using compiler instead

COS 318: Operating Systems

Communication in Distributed Systems

DISTRIBUTED FILE SYSTEMS & NFS

Filesystems Lecture 11

Separating Access Control Policy, Enforcement, and Functionality in Extensible Systems. Robert Grimm University of Washington

Page 1. Goals for Today" Remote Procedure Call" Raw messaging is a bit too low-level for programming! RPC Details"

SPIN Operating System

Distributed File Systems: Design Comparisons

Network File Systems

File-System Structure

Distributed file systems

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

Distributed Systems Principles and Paradigms

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

Dr. Robert N. M. Watson

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

struct foomsg { u_int32_t len; }

Chapter 11: File System Implementation

Last Class: RPCs. Today:

Chapter 11: File System Implementation

Chapter 11: Implementing File Systems

RMI & RPC. CS 475, Spring 2019 Concurrent & Distributed Systems

殷亚凤. Processes. Distributed Systems [3]

Lecture 06: Distributed Object

Distributed File Systems

416 Distributed Systems. RPC Day 2 Jan 12, 2018

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

DISTRIBUTED SYSTEMS [COMP9243] Lecture 9b: Distributed File Systems INTRODUCTION. Transparency: Flexibility: Slide 1. Slide 3.

Today: Distributed File Systems. File System Basics

Verteilte Systeme (Distributed Systems)

ECE454 Tutorial. June 16, (Material prepared by Evan Jones)

Networks and Operating Systems Chapter 3: Remote Procedure Call (RPC)

Today: Distributed File Systems

06-Dec-17. Credits:4. Notes by Pritee Parwekar,ANITS 06-Dec-17 1

Distributed File Systems. Directory Hierarchy. Transfer Model

Chapter 11: Implementing File Systems

Distributed Systems. The main method of distributed object communication is with remote method invocation

DISTRIBUTED COMPUTER SYSTEMS

Chapter 12 File-System Implementation

Chapter 11: Implementing File-Systems

Qualifying exam: operating systems, 1/6/2014

File-System Interface

Extensibility, Safety, and Performance in the Spin Operating System

Distributed File Systems. CS432: Distributed Systems Spring 2017

Communication. Distributed Systems Santa Clara University 2016

Announcements. P4: Graded Will resolve all Project grading issues this week P5: File Systems

COS 318: Operating Systems

CS533 Concepts of Operating Systems. Jonathan Walpole

Week 11/12: Distributed File Systems & RPC Reading: Text, Chapter 8.2.4, 8.3,

Distributed systems. Programming with threads

Remote Procedure Call. Tom Anderson

6.033 Spring 2004, Quiz 1 Page 1 of Computer Systems Engineering: Spring Quiz I

Monitoring Network File Systems

Distributed File Systems. Distributed Systems IT332

NETWORKED STORAGE AND REMOTE PROCEDURE CALLS (RPC)

Xen and the Art of Virtualization. CSE-291 (Cloud Computing) Fall 2016

03 Remote invoaction. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

416 Distributed Systems. Distributed File Systems 2 Jan 20, 2016

Building up to today. Remote Procedure Calls. Reminder about last time. Threads - impl

Remote Invocation. Today. Next time. l Indirect communication. l Request-reply, RPC, RMI

May Gerd Liefländer System Architecture Group Universität Karlsruhe (TH), Systemarchitektur

Chapter 5: Remote Invocation. Copyright 2015 Prof. Amr El-Kadi

Chapter 3: Client-Server Paradigm and Middleware

Client Server & Distributed System. A Basic Introduction

Confinement (Running Untrusted Programs)

5 Distributed Objects: The Java Approach

REMOTE PROCEDURE CALLS EE324

CAS 703 Software Design

Transcription:

How do modules communicate? Enforcing modularity Within the same address space and protection domain local procedure calls Across protection domain system calls Over a connection client/server programming model Remote Procedure Call socket (local or across the network) Modularity: client-server organization All communication through messages modules are isolated propagation of errors is reduced cfr. soft modularity in procedure calls Encourages a clean design even within a single computer! modules can be thought of on separate computers Tradeoffs of enforcing modularity Module granularity tend to be coarser crossing a layer of abstraction is more expensive! to amortize, each message may elicit significant computation e.g. databases, fileservers Many design decisions how much client state should a server keep? how should modules handle their partner s failure? does the server trust the client? does the client trust the server?

Remote Procedure Call (RPC) Building a server Birrell & Nelson, 1984 Hide message passing I/O from programmer Server interface defined via an Interface Definition Language specifies names, parameters, types of client-callable procedures Make RPC look as much as possible as PC Stub compiler reads IDL to produce client and server stubs Three components on each side user program (client or server) stubs manage all details of remote communication (compiled) stubs Server developer links server code with serverside stub similarly at the client RPC runtime support RPC Call structure client program client calls locally stub proc. call foo (x,y) call foo client stub server program client program stub unmarshalls params and makes call stub builds msg, marshalls params proc foo (a,b) call foo (x,y) server stub client stub runtime receives message and calls stub Communication on top of XDR these days, on top of web services RESTful APIs, AJAX. client continues proc foo (a,b) begin foo end foo server proc. returns proc foo (a,b) RPC runtime RPC runtime server program return stub unmarshalls msg, returns to caller stub builds msg, marshalls output args msg received msg received runtime sends message to remote node call foo (x,y) return call foo send msg RPC runtime proc foo (a,b) begin foo end foo server called by its stub RPC Return structure call foo (x,y) server stub send msg runtime receives msg, calls stub runtime responds to original msg Communication on top of XDR these days, on top of web services RESTful APIs, AJAX. RPC runtime

RPC binding RPC is not PC Server On startup, exports its interface identifies itself to a network name server tell local runtime its dispatcher address Client Before issuing any calls, imports server RPC runtime looks up server through name service and contacts it to create a connection if succeeds: at least one execution if fails: none, partial, multiple if succeeds: exactly once if fails: none, if succeeds: exactly once if fails: none, partial, one No shared address space no pointers; data structures must be fully marshalled Performance cost of procedure call << same machine RPC << network RPC Fate sharing client and server fail independently fault-tolerance handled end-to-end three execution semantics At least once (SUN RPC) At most once (Java RMI, HTTP) Exactly once implemented by retransmission on timeout works only if operation is idempotent implemented by server filtering duplicate requests Needs updating persistent state at the server on every receipt What granularity of protection within OS? Monolithic kernel no protection within kernel hard to modify, debug, validate Fine-grained protection with capabilities objects share address space but have individual protection domain difficult to implement efficiently and develop for Small kernel functionalities are in separate, larger domains/address spaces, communicating via RPC better fault-isolation, debugging, easier implementation/maintenance The catch RPC is general, but inefficient procedure Null() begin return end Null Theoretical minimum time Cross domain performance over six system is 300% to over 800% that of theoretical min pressure to colocate logically distinct functionalities in single domain { procedure call kernel trap X 2 VM context switch

Handle normal case and worst case separately B. Lampson. Hints for Computer Systems Design 1. Few cross-domain calls cross machine boundaries 0.6% (SUN Unix+NFS); 3% (V); 5.3% (Taos) 2. Most calls send few bytes 3. No need for complex marshalling byte copy suffices Lightweight RPC A combination of protected and remote procedure calls Executions model: protected procedure call call to server made through kernel trap kernel validates caller, creates linkage (?), dispatches client s concrete thread to server upon procedure s completion, kernel returns control to client Semantics: RPC server exports interfaces clients bind interfaces large-grain protection model Bershad, Anderson, Lozowska, Levy 1990 LRPC binding Conceptually similar to RPC Server exports interface to name server; client imports (via kernel call) but different implementation mediated by the kernel server s clerk returns to kernell a procedure descriptor (PD) list one PD per exported procedure LRPC binding: mechanisms Procedure descriptor procedure s entry address in server domain count C of permitted simultaneous invocation size of the procedure s argument stack (A-stack) A-stack holds arguments and return values for a call r/w addressable by both client and server kernel allocates C A-stacks upon binding, client learns location of A-stacks for procedures in interface

LRPC binding: mechanisms LRPC calls Linkage record stores caller s return address only accessible by kernel one per A-stack, easy to refer to from A-stack Binding object returned once binding completes a capability to access the server interface must be presented at each call Client s stub Kernel LRPC calls LRPC calls Client s stub Kernel Client s stub Kernel picks an A-stack pushes procedure s arguments loads registers with A-stack s address Binding Object ID of procedure traps to kernel picks an A-stack pushes procedure s arguments loads registers with A-stack s address Binding Object ID of procedure traps to kernel verifies BO and procedure ID, locates PD verifies A-stack; find its linkage ensures A-stack, linkage are unused stores caller s return address in linkage pushes linkage on stack of linkages in TCB finds an execution stack (E-stack) in server s domain sets threads SP to use E- stack changes VM registers upcalls in server s stub to procedure s address specified in PD

LRPC returns Server s stub traps to the kernel no need to verify rights: they were granted at call time client-specified A-stack contains return values NO EXPLICIT MESSAGE PASSING! Call by reference Fun details objects passed by reference are copied on A-stack server creates a reference to address in A-stack E-stack/A-stack pairing dynamic (E-stacks can be large!) Leveraging multiprocessors to reduce c-switch overhead Calling thread placed on idle processor in server s domain context (and viceversa on return!) Reducing argument copying client s stub s stack to RPC message RPC message to kernel one copy to A-stack kernel to RPC message RPC message to server s stub The uncommon cases The uncommon cases Call to a truly remote server detected on first stub instruction bit set in the BO Size of A-stack easy if arguments known at compile time. If not stub sets size to Ethernet packet can be overridden; can use out-of-band memory segment Domain termination if server s, client s outstanding call must return if client s, outstanding calls should not return The kernel revokes BOs for terminated domain no more in or out calls! client threads with outstanding LRPC are restarted with call-failed exception active linkage records are invalidated invalid linkage record on return raises call-failed exception in caller

Looking back Four techniques key to LRPC s performance Simple control transfer client s thread executes requested procedure in server s domain Simple data transfer as in PC, shared argument stack elinates redundant copies Simple stubs because data and cotrol transfers are simple, so are stubs Design for concurrency leverages potential speedup from multiprocessors NFS Sun s Network File System NFS Sun s Network File System Mid 80s the dawn of a new era! individual workstations potentially diskless NFS aims to provide a shared file system saves money easy to share and backup files RPC is its core mechanism Sun-1, 1982 Goals Compatible with existing applications aim for same semantics as a UNIX file system Easy to deploy should retrofit into existing UNIX systems Not too UNIX specific should work with DOS Efficient enough adequate, but not necessarily as fast as a local file system

Using NFS Key design choice Same user interface as UNIX FS OPEN ( /users/lorenzo/pong.c, READONLY) Easy to deploy host : path % mount -t nfs 10.131.248.8:/nfs/dir /mnt/nfs/dir RPC to host, asking for a file handle for the object identified by path all future RPCs for that object include its file handle Stateless server RPC arguments contain all information necessary to carry out request Server maintains no other state than on-disk files Example: fd open( f, readonly) read( fd, buf, n) close( fd ) What should a file handle include? Application NFS Client NFS Server open( f,0) Lookup(, f ) dirfh The path name of the requested object Program 1 on client 1 Program 2 on client 2 fd read( fd, buf, n) fh and file attributes read( ) fh, 0,n Look up f in directory dirfh 1. 2. chdir( dir1 ) fd open( f,readonly) 3. rename( dir1, dir2 ) 4. rename( dir3, dir1 ) 5. read( fd, buf, n) Data Data and file attributes Read from fh Which file should be read? close( fd ) In Unix, it would be dir2/f NFS would like to keep that behavior

Extending the UNIX FS to support NFS The file handle Client Inode number User program File system identifier Program 1 on client 1 Server open(name,flags) File system call layer Program 2 on client 2 File system call layer fd 1. 2. unlink( f ) 3. 4. fd open( f,readonly) Vnode layer what happens in Unix? read( fd, buf, n ) Generation number Local file system incremented every time inode is reused Extending the UNIX FS to support NFS open(name,flags) File system call layer Vnode layer Local file system 1. pathname_to_vnode, with params Vnode of wd, and path name NFS client 6. Server returns file handle for Vnode lookup(fhwd, hame) RPC stubs 7. At client, NFS client creates Vnode (with file handle) and returns it to file system layer 8. Once full path resolved, return fd for file Network RPC stubs Caching: joys and tribulations vnode for every open file File system call layer 4. Lookup in Vnode layer, with path as argument lookup(fhwd, name) RPC stubs NFS client caches 3. At server, use dir file handle to find dir s Vnode 5. If file exists, create Vnode for it lookup(fhwd, hame) NFS client lookup(fhwd, name) Server 2a. If Vnode maps to local dir, then lookup in local FS 2b. Otherwise take wd file handle and path and send to NFS client, which starts an RPC NFS client Network Not quite the same semantics as UNIX User program Vnode layer lookup(fhwd, name) open( f,create) Client file handle of wdir + pathname recently used blocks of cached vnodes Vnode layer NFS client lookup(fhwd, name) RPC stubs recently used vnodes Local file system mapping from path name to vnode Lower latency, lower load on server What about coherence? Local file system

Coherence A read returns the result of the latest completed write with caching? write-through? NFS implements coherence only for certain operations Close-to-open consistency A client that opens f, will see the result of all writes to f performed by clients who have previously closed f. blocks cached at client have a timestamp recording last known modification of corresponding Vnode on open, NFS client contacts server to learn current timestamp of Vnode reads cached blocks only if retrieved timestamp is no larger on close, client first sends modified blocks, and waits for acks before returning What if the server crashes? Morto un Papa, se ne fa un altro Italian proverb Stateless server