Download presentation
Presentation is loading. Please wait.
1
Slide 17-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17
2
Slide 17-2 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 17 Distributed Computing
3
Slide 17-3 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Distributed Computation Using Files Part 1 Part 2 f1 = open(toPart2, …); while(…){ write(f1. …); } close(f1); … f2 = open(toPart1, …); while(…){ write(f2. …); } close(f2); f2 = open(toPart2, …); while(…){ read(f1, …); } close(f1); f2 = open(toPart1, …); while(…){ read(f2, …); } close(f2);
4
Slide 17-4 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Finer Grained Sharing Distributed computing can be for: –Speed up (simultaneous execution) –Simplify data management (consistency) Last Generation: programming languages (and programmers) do serial computation –Want to share global data –Speed up is a specialist’s domain Procedure is basic unit of abstraction –Abstract data type behavior
5
Slide 17-5 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Finer Grained Sharing (2) Newer computing model –Partition into processes/threads –Message passing communication New OS & language support –Remote procedures –Remote objects with remote method invocation –Distributed process management –Shared memory –Distributed virtual memory … but first, how to partition the computations?
6
Slide 17-6 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Data Partition Serial Form of code while(…){…} Distribute Data Serial Form Execute all data streams simultaneously
7
Slide 17-7 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Functional Partition Serial Form of code A Partition The Parts
8
Slide 17-8 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Functional Partition (2) Software is composed from procedures All programmers are familiar with procedural abstraction – exploit procedure model Allow each function to be a blob Implement each blob as a thread/process OS provide network IPC mechanism for serial use of distributed functions –TCP/IP –Messages –“Procedure call” protocol between client and server
9
Slide 17-9 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Record Sharing Part 1 Part 2 … while(…){ writeSharedRecord(…); readSharedRecord(…); } … while(…){ readSharedRecord(…); writeSharedRecord(…); } …
10
Slide 17-10 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Traditional Memory Interfaces Process Virtual Memory Virtual Memory File Management File Management Physical Memory Physical Memory Storage Devices Storage Devices Device Interface Secondary Memory InterfacePrimary Memory Interface
11
Slide 17-11 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Exploiting Normal Interfaces to the Memory System Process Virtual Memory Virtual Memory File Management File Management Physical Memory Physical Memory Storage Devices Storage Devices File System InterfacePrimary Memory Interface Remote Disk Client Remote Disk Client Remote Disk Server Remote Disk Server Remote File Client Remote File Client Remote File Server Remote File Server Privileged Use Only
12
Slide 17-12 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Remote Memory Process File Management File Management Remote Memory Interface Remote Memory Client Remote Memory Client Remote Memory Server Remote Memory Server Static memory New language Dynamic memory New OS interface Low level interface Binding across address spaces Shared memory malloc High level interface Tuples Objects
13
Slide 17-13 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Distributed Virtual Memory Process Virtual Memory Virtual Memory Physical Memory Physical Memory Storage Devices Storage Devices Primary Memory Interface Remote Paging Client Remote Paging Client Remote Paging Server Remote Paging Server Storage Devices Storage Devices
14
Slide 17-14 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Distributed Virtual Memory(2) Process 1 Primary Memory Space Primary Memory Space Local Secondary Memory Local Secondary Memory Virtual Address Space map Remote Secondary Memory Remote Secondary Memory Server Process 2 Primary Memory Space Primary Memory Space Local Secondary Memory Local Secondary Memory Virtual Address Space map
15
Slide 17-15 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Remote Procedure Call int main(…) { … func(a1, a2, …, an); … } void func(p1, p2, …, pn) { … } int main(…) { … func(a1, a2, …, an); … } void func(p1, p2, …, pn) { … } Conventional Procedure Call Remote Procedure Call
16
Slide 17-16 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Remote Procedure Call int main(…) { … func(a1, a2, …, an); … } void func(p1, p2, …, pn) { … } … pack(a1, msg); pack(a2, msg); … pack(an, msg); send(rpcServer, msg); // waiting... result = receive(rpcServer);... // Initialize the server while(TRUE) { msg = receive(anyClient); unpack(msg, t1); unpack(msg, t2); … unpack(msg, tn); func(t1, t2, …, tn); pack(a1, rtnMsg); pack(a2, rtnMsg); … pack(an, rtnMsg); send(rpcServer, rtnMsg); }
17
Slide 17-17 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Implementing RPC Syntax of an RPC should look as much like a local procedure call as possible Semantics are impossible to duplicate, but they should also be as close as possible The remote procedure’s execution environment will not be the same as a local procedure’s environment –Global variables –Call-by-reference –Side effects –Environment variables
18
Slide 17-18 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Implementing RPC int main(…) { … localF(…); … remoteF(…); … } void localF(…) { … return; } lookup(remote); pack(…); send(rpcServer, msg); receive(rpcServer); unpack(…); return; register(remoteF); while(1) { receive(msg); unpack(msg); remoteF(…); pack(rtnMsg); send(theClient,rtnMsg); } clientStub main theClient void remoteF(…) { … return; } void register(…) { … } void lookup(…) { … } Name Server rpcServer First Time Only
19
Slide 17-19 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Compiling an RPC callRemote(remoteF, …); remoteF(…); –Compile time –Link time –Dynamic binding
20
Slide 17-20 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Sun XDR Conversion Client RPC Server XDR conversion XDR conversion XDR Spec XDR conversion XDR conversion Network XDR Transmit
21
Slide 17-21 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Sun rpcgen Files main.c rproc.x rproc_clnt.c rproc.h rproc_svc.c rproc.c rpcgen C compiler RPC client RPC server
22
Slide 17-22 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Distributed Object Interface Process Object Interface Remote Object Client Remote Object Client Remote Object Server Remote Object Server Local Objects Process Remote Object Interface Remote Object Client Remote Object Client Remote Object Server Remote Object Server Local Objects Local Object Interface Performance e.g. Corba, DCOM, SOAP, … (a) Single Interface to Objects (b) Interface to Local and Remote Objects
23
Slide 17-23 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 IDL Skeleton The CORBA Approach Client Object Implementation Object Implementation ORB Interface ORB Core IDL Stub Stub Implement IDL Skeleton Dynamic Skel. Dynamic Skel Dynamic Stub Dynamic Stub. Object Adaptor Interface Repository
24
Slide 17-24 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Supporting the Computation Each blob might be a process, thread, or object Blobs should be able to run on distinct, interconnected machines OS must provide mechanisms for: –Process Management Control Scheduling Synchronization IPC –Memory Management Shared memory –File Management – remote files Distributed OS or cooperating Network OSes?
25
Slide 17-25 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Control Remote process/thread create/destroy Managing descriptors Deadlock
26
Slide 17-26 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Scheduling Threads and processes Explicit scheduling Transparent scheduling Migration & load balancing Objects –Active vs passive –Address spaces
27
Slide 17-27 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Migration and Load Balancing p p A thread or process Machine A Machine B Machine C p p p p p p p p p p p Machine A Machine B Machine C p p p p p p p p p p (a) Before Balancing(b) After Balancing
28
Slide 17-28 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Synchronization Distributed synchronization –No shared memory no semaphores –New approaches use logical clocks & event ordering Transactions –Became a mature technology in DBMS –Multiple operations with a commit or abort Concurrency control –Two-phase locking
29
Slide 17-29 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Updating a Multiple Field Record Process piProcess pj... send(server, update, k, 3);send(server, update, k, 5); send(server, update, k, 6);send(server, update, k, 8); send(server, update, k, 2);send(server, update, k, 4); send(server, update, k, 8);send(server, update, k, 6);...
30
Slide 17-30 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Explicit Event Ordering Alternative technique of growing importance in network systems Rely on knowing the relative order of occurrence of every event –(occurrence of y in p j ) < (occurrence of x in p i ) –Then can synchronize by explicitly specifying each relation (when it is important) advance(eventCount): Announces the occurrence of an event related to eventCount, causing it to be incremented by 1 await(eventCount, v): Causes process to block as long as eventCount < v.
31
Slide 17-31 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 Producer-Consumer Solution Using Precedence producer() {consumer() {/* i establishes local order */ int i = 1; while(TRUE) { /* Stay N–1 ahead of consumer */ /* Stay N–1 behind producer */ await(out, i-N); await(in, i); produce(buffer[(i–1) mod N]); consume(buffer[(I–1) mod N]; /* Signal a full buffer */ /* Signal an empty buffer */ advance(in); advance(out); i = i+1; }} eventcount in=0, out=0; struct buffer[N]; fork(producer, 0); fork(consumer, 0);
32
Slide 17-32 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 17 More on EventCounts Notice that advance and await need not be uninterruptible There is no requirement for shared memory For full use of this mechanism, actually need to extend it a bit with a sequencer Underlying theory is also used to implement “virtual global clocks” in a network Emerging as a preferred synchronization mechanism on networks
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.