Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Processes Chapter 3. 2 Processes  Communication takes place between processes. But, what ’ s a process?  “ A program in execution ”  Traditional.

Similar presentations


Presentation on theme: "1 Processes Chapter 3. 2 Processes  Communication takes place between processes. But, what ’ s a process?  “ A program in execution ”  Traditional."— Presentation transcript:

1 1 Processes Chapter 3

2 2 Processes  Communication takes place between processes. But, what ’ s a process?  “ A program in execution ”  Traditional operating systems: concerned with the “ local ” management and scheduling of processes.  Modern distributed systems: a number of other issues are of equal importance.  There are three main areas of study: 1. Threads (within clients/servers). 2. Process and code migration. 3. Software agents.

3 3 Introduction to Threads  Modern OSes provide “ virtual processors ” within which programs execute.  A programs execution environment is documentated in the process table and assigned a PID.  To achieve acceptable performance in distributed systems, relying on the OS ’ s idea of a process is often not enough - finer granularity is required.  The solution: Threading.

4 4 Threads  Process A program in execution, or A program is currently being executed on one of the OS ’ s virtual processors.  Process table Entries to CPU register values, memory maps, open files, accounting infor., privileges, etc.  Cost highly Saving CPU context, e.g., register values, program counter, stack pointers, etc. Modify registers of the memory management unit (MMU) Invalidate address translation caches such as in the translation lookaside buffer (TLB) Swapping processes Occupies main memory simultaneously  Thread Thread context consists of nothing more than the CPU context.

5 5 Benefits of Threads  A single-thread process The process as a whole is blocked whenever a blocking system call is executed. For example, a spreadsheet program  Multithreading Becomes possible to exploit parallelism Useful in the context of large applications  One application, several cooperating programs, each to be executed by a separate process.  Interprocess communication (IPC) is needed if cooperating programs are implemented.  When IPC is invoked, it requires changing the memory map in the MMU, as well as flushing the TLB.

6 6 Two Important Implications 1. Threaded applications often run faster than non- threaded applications (as context-switches between kernel and user-space are avoided). 2. Threaded applications are harder to develop (although simple, clean designs can help here). 3. Additionally, the assumption is that the development environment provides a Threads Library for developers to use (most modern environments do).

7 7 Thread Implementation  Tow approaches to implement a thread package To construct a thread library that is executed entirely in user mode To have the kernel be aware of threads and schedule them  User-level thread Easy to create and destroy Creating a thread is primarily determined by the cost for allocating memory to set up a thread stack. Destroying a thread involves freeing memory for the stack. Switching thread context can be done in a few instructions. Drawbacks:  Encounter a blocking system call (e.g., I/O)

8 8 Threads in Non-Distributed Systems  Advantages: 1. Blocking can be avoided 2. Excellent support for multi-processor systems (each running their own thread). 3. Expensive context-switches can be avoided. 4. For certain classes of application, the design and implementation is made considerably easier.

9 9 Threads in Distributed Systems  Important characteristic: a blocking call in a thread does not result in the entire process being blocked.  The leads to the key characteristic of threads within distributed systems: “ We can now express communications in the form of maintaining multiple logical connections at the same time (as opposed to a single, sequential, blocking process). ”

10 10 Example: MT Clients and Servers  Mutli-Threaded Client: to achieve acceptable levels of perceived performance, it is often necessary to hide communications latencies.  Consequently, a requirement exists to start communications while doing something else.  Example: modern web browsers.  This leads to the notion of “ truly parallel streams of data ” arriving at a multi-threaded client application.

11 11 Example: MT-Servers  Although threading is useful on clients, it is much more useful in distributed systems servers.  The main idea is to exploit parallelism to attain high performance.  A typical design is to organize the server as a single “ dispatcher ” with multiple threaded “ workers ”, as diagrammed overleaf.

12 12 Multi-Threaded Servers (1)  A multithreaded server organized in a dispatcher/worker model.

13 13 Multi-Threaded Servers (2)  Three ways to construct a server. ModelCharacteristics ThreadsParallelism, blocking system calls Single-threaded processNo parallelism, blocking system calls Finite-state machineParallelism, nonblocking system calls hard to implement

14 14 More on Clients and Servers  What ’ s a client?  Definition: “ A program which interacts with a human user and a remote server. ”  Typically, the user interacts with the client via a GUI.  Of course, there ’ s more to clients than simply providing a UI. Remember the multi- tiered levels of the Client/Server architecture from earlier …

15 15 Multi-Tiered Client Architectures

16 16 The X-Window System  The basic organization of the X Window System

17 17 Client-Side Software for Distribution Transparency  A possible approach to transparent replication of a remote object using a client-side solution.

18 18 What ’ s a Server?  Definition: “ A process that implements a specific service on behalf of a collection of clients ”.  Typically, servers are organized to do one of two things: 1. Wait 2. Service … wait … service … wait … service … wait …

19 19 Servers: Iterative and Concurrent  Iterative: server handles request, then returns results to the client; any new client requests must wait for previous request to complete (also useful to think of this type of server as sequential).  Concurrent: server does not handle the request itself; a separate thread or sub- process handles the request and returns any results to the client; the server is then free to immediately service the next client (i.e., there ’ s no waiting, as service requests are processed in parallel).

20 20 Problem: Identifying “ end-points ” ?  How do clients know which end-point (or port) to contact a server at? How do they “ bind ” to a server?  Statically assigned end-points (IANA, Internet Assigned Numbers Authority). FTP, TCP port 21 HTTP, TCP port 80.  Dynamically assigned end-points (DCE).  A popular variation:  the “ super-server ” (inetd on UNIX).

21 21 Servers: General Design Issues a) Client-to-server binding using a daemon (DCE) b) Client-to-server binding using a super-server (inetd on UNIX) 3.7

22 22 Server “ States ”  Stateless servers – no information is maintained on the current “ connections ” to the server. The web is the classic example of a stateless service. As can be imagined, this type of server is easy to implement.  Stateful servers – information is maintained on the current “ connections ” to the server. Advanced file servers, where copies of a file can be updated “ locally ” then applied to the main server (as the server knows the state of things). These are more difficult to implement.  But, what happens if something crashes?  (More on this later, see chapter 7).

23 23 A Special Type: Object Servers  A server tailored to support distributed objects.  Does not provide a specific service.  Provides a facility whereby objects can be remotely invoked by non-local clients.  Consequently, object servers are highly adaptable.  “ A place where objects live ”.

24 24 Code Migration  Under certain circumstances, in addition to the usual passing of data, passing code (even while it is executing) can greatly simplify the design of a distributed system.  However, code migration can be inefficient and very costly.  So, why migrate code?

25 25 Reasons for Migrating Code  Why?  Biggest single reason: better performance.  The big idea is to move a compute- intensive task from a heavily loaded machine to a lightly loaded machine “ on demand ” and “ as required ”.

26 26 Code Migration Examples  Moving (part of) a client to a server – processing data close to where the data resides. It is often too expensive to transport an entire database to a client for processing, so move the client to the data.  Moving (part of) a server to a client – checking data prior to submitting it to a server. The use of local error-checking (with JavaScript) on web forms is a good example of this type of processing. Error-check the data close to the user, not at the server.

27 27 “ Classic ” Code Migration Example  Searching the web by “ roaming ”.  Rather than search and index the web by requesting the transfer of each and every document to the client for processing, the client relocates to each site and indexes the documents it finds “ in situ ”. The index is then transported from site to site, in addition to the executing process.

28 28 Reasons for Migrating Code  The principle of dynamically configuring a client to communicate to a server. The client first fetches the necessary software, and then invokes the server.

29 29 Major Disadvantage  Security Concerns.  “ Blindly trusting that the downloaded code implements only the advertised interface while accessing your unprotected hard-disk and does not send the juiciest parts to heaven-knows-where may not always be such a good idea ”.

30 30 Code Migration Models  A running process consists of three “ segments ” : Code Segment – instructions  The part that contains the set of instructions that make up the program that is being executed. Resource Segment – external references.  The part that contains references to external resources needed by the process, such as files, printers, devices, other processes, and so on. Execution Segment – current state.  Used to store the current execution state of a process, consisting of private data, the stack, and the program counter.

31 31 Code Migration Characteristics  Weak Mobility: just the code is moved – and it always restarts from its initial state.  e.g. Java Applets.  Comment: simple implementation, but limited applicability.  Strong Mobility: the code and the state is moved – and execution restarts from the next statement.  e.g. D ’ Agents.  Comment: very powerful, but hard to implement.

32 32 More Characteristics  Sender- vs. Receiver-Initiated.  Which side of the communication starts the migration?  The machine currently executing the code (known as sender-initiated), or  The machine that will ultimately execute the code (known as receiver-initiated).

33 33 How Does the Migrated Code Run?  Another issue surrounds where the migrated code executes: - Within an existing process (possibly as a thread) - or - Within it ’ s own (new) process space. - Finally, strong mobility also supports the notion of “ remote cloning ” : an exact copy of the original process, but now running on a different machine.

34 34 Models for Code Migration  Alternatives for code migration.

35 35 What About Resources?  This is tricky.  What makes code migration difficult is the requirement to migrate resources.  Resources are the external references that a process is currently using, and includes (but is not limited to):  Variables, open files, network connections, printers, databases, etc.

36 36 Types of Process-to-Resource Binding  Strongest: binding-by-identifier (BI) – precisely the referenced resource, and nothing else, has to be migrated.  Binding-by-value (BV) – weaker than BI, but only the value of the resource need be migrated.  Weakest: binding-by-type (BT) – nothing is migrated, but a resource of a specific type needs to be available after migration (eg, a printer).

37 37 More Resource Classification  Resources are further distinguished as one of: 1. Unattached: a resource that can be moved easily from machine to machine. 2. Fastened: migration is possible, but at a high cost. 3. Fixed: a resource is bound to a specific machine or environment, and cannot be migrated.  Refer to diagram 3-14 in the textbook for a good summary of resource-to-binding characteristics (to find out what to do with which resource when).

38 38 Migration and Local Resources  Actions to be taken with respect to the references to local resources when migrating code to another machine. UnattachedFastenedFixed By identifier By value By type MV (or GR) CP ( or MV, GR) RB (or GR, CP) GR (or MV) GR (or CP) RB (or GR, CP) GR RB (or GR) Resource-to machine binding Process-to- resource binding

39 39 Migration in Heterogeneous Systems  The principle of maintaining a migration stack to support migration of an execution segment in a heterogeneous environment 3-15

40 40 Software Agents  What is a software agent?  “ An autonomous unit capable of performing a task in collaboration with other, possibly remote, agents ”.  The field of Software Agents is still immature, and much disagreement exists as to how to define what we mean by them.  However, a number of types can be identified.

41 41 Types of Software Agent  Collaborative Agent – also known as “ multi-agent systems ”, which can work together to achieve a common goal (eg, planning a meeting).  Mobile Agent – code that can relocate and continue executing on a remote machine.  Interface Agent – software with “ learning abilities ” (that damned MS paperclip, and the ill-fated “ bob ” ).  Information Agent – agents that are designed to collect and process geographically dispersed data and information.

42 42 Implementation Issues (1)  The architecture of the D'Agents system.

43 43 Implementation Issues (2)  The parts comprising the state of an agent in D'Agents. StatusDescription Global interpreter variablesVariables needed by the interpreter of an agent Global system variablesReturn codes, error codes, error strings, etc. Global program variablesUser-defined global variables in a program Procedure definitionsDefinitions of scripts to be executed by an agent Stack of commandsStack of commands currently being executed Stack of call framesStack of activation records, one for each running command

44 44 Software Agents in Distributed Systems  Some important properties by which different types of agents can be distinguished. Property Common to all agents? Description AutonomousYesCan act on its own ReactiveYesResponds timely to changes in its environment ProactiveYesInitiates actions that affects its environment CommunicativeYesCan exchange information with users and other agents ContinuousNoHas a relatively long lifespan MobileNoCan migrate from one site to another AdaptiveNoCapable of learning

45 45 Agent Technology  The general model of an agent platform (adapted from [fipa98-mgt]).

46 46 Agent Technology - Standards  The general model of an agent platform has been standardized by FIPA (The “ Foundation for Intelligent Physical Agents ” ) located at the http://www.fipa.org website.  Specifications include: Agent Management Component. Agent Directory Service. Agent Communication Channel. Agent Communication Language.

47 47 Agent Communication Languages (1)  Examples of different message types in the FIPA ACL [fipa98-acl], giving the purpose of a message, along with the description of the actual message content. Message purposeDescriptionMessage Content INFORMInform that a given proposition is trueProposition QUERY-IFQuery whether a given proposition is trueProposition QUERY-REFQuery for a give objectExpression CFPAsk for a proposalProposal specifics PROPOSEProvide a proposalProposal ACCEPT-PROPOSALTell that a given proposal is acceptedProposal ID REJECT-PROPOSALTell that a given proposal is rejectedProposal ID REQUESTRequest that an action be performedAction specification SUBSCRIBESubscribe to an information sourceReference to source

48 48 Agent Communication Languages (2)  A simple example of a FIPA ACL message sent between two agents using Prolog to express genealogy information. FieldValue PurposeINFORM Sendermax@http://fanclub-beatrix.royalty-spotters.nl:7239 Receiverelke@iiop://royalty-watcher.uk:5623 LanguageProlog Ontologygenealogy Contentfemale(beatrix),parent(beatrix,juliana,bernhard)

49 49 Summary - Processes  Processes play a fundamental role in DS ’ s.  Threads play a central role in building systems that don ’ t BLOCK when performing I/O – key requirement.  The “ classic ” process organization model is client/server, and we looked at the various ways to organize the client and the server components.  “ Object Servers ” are a special case.  Processes can migrate from system-to-system: for performance and flexibility reasons.  Although a simple, and easy to understand, idea, actually realizing this is not that simple (especially within heterogeneous environments).  Standards are immature in this area, but are gaining support within the community (eg, FIPA).

50 50 Homework Assignment  You are to produce a five page report on GRID COMPUTING.  This is a topic that has generated considerable interest within both the academic and commercial distributed computing communities.  Your five page report should answer the following questions and address the following points: What is GRID COMPUTING (GC)? How does GC differ from traditional distributed computing environments? Why is GC important? What type of distributed systems is GC suited to? Identify three GC environments? What plaforms do they run on? Is GC just another distributed computing fad?  Format: A4, typed, bound, single-spaced, 12pt. A cover page should also be included, as should a page of annotated references (and these are NOT counted as one of the pages).


Download ppt "1 Processes Chapter 3. 2 Processes  Communication takes place between processes. But, what ’ s a process?  “ A program in execution ”  Traditional."

Similar presentations


Ads by Google