1 processes chapter 3. 2 processes communication takes place between processes. but, what ’ s a...

50
1 Processes Chapter 3

Upload: alaina-marshall

Post on 29-Dec-2015

225 views

Category:

Documents


0 download

TRANSCRIPT

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

1

Processes

Chapter 3

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

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.

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

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.

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

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.

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

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.

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

6

Two Important Implications1. 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).

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

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)

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

8

Threads in Non-Distributed Systems Advantages:

1. Blocking can be avoided2. 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.

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

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).”

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

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.

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

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.

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

12

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

model.

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

13

Multi-Threaded Servers (2)

Three ways to construct a server.

Model Characteristics

Threads Parallelism, blocking system calls

Single-threaded process No parallelism, blocking system calls

Finite-state machine Parallelism, nonblocking system calls

hard to implement

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

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 …

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

15

Multi-Tiered Client Architectures

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

16

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

System

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

17

Client-Side Software for Distribution Transparency A possible approach to transparent replication of a

remote object using a client-side solution.

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

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. Wait2. Service

… wait … service … wait … service … wait …

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

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).

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

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).

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

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

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

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).

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

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”.

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

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?

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

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”.

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

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.

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

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.

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

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.

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

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”.

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

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.

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

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.

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

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).

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

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.

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

34

Models for Code Migration

Alternatives for code migration.

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

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.

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

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).

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

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).

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

38

Migration and Local Resources

Actions to be taken with respect to the references to local resources when migrating code to another machine.

Unattached Fastened Fixed

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

GR

RB (or GR)

Resource-to machine binding

Process-to-resource

binding

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

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

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

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.

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

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.

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

42

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

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

43

Implementation Issues (2) The parts comprising the state of an agent in D'Agents.

Status Description

Global interpreter variables Variables needed by the interpreter of an agent

Global system variables Return codes, error codes, error strings, etc.

Global program variables User-defined global variables in a program

Procedure definitions Definitions of scripts to be executed by an agent

Stack of commands Stack of commands currently being executed

Stack of call frames Stack of activation records, one for each running command

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

44

Software Agents in Distributed Systems

Some important properties by which different types of agents can be distinguished.

PropertyCommon to all agents?

Description

Autonomous Yes Can act on its own

Reactive Yes Responds timely to changes in its environment

Proactive Yes Initiates actions that affects its environment

Communicative Yes Can exchange information with users and other agents

Continuous No Has a relatively long lifespan

Mobile No Can migrate from one site to another

Adaptive No Capable of learning

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

45

Agent Technology The general model of an agent platform (adapted from

[fipa98-mgt]).

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

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.

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

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 purpose Description Message Content

INFORM Inform that a given proposition is true Proposition

QUERY-IF Query whether a given proposition is true Proposition

QUERY-REF Query for a give object Expression

CFP Ask for a proposal Proposal specifics

PROPOSE Provide a proposal Proposal

ACCEPT-PROPOSAL Tell that a given proposal is accepted Proposal ID

REJECT-PROPOSAL Tell that a given proposal is rejected Proposal ID

REQUEST Request that an action be performed Action specification

SUBSCRIBE Subscribe to an information source Reference to source

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

48

Agent Communication Languages (2)

A simple example of a FIPA ACL message sent between two agents using Prolog to express genealogy information.

Field Value

Purpose INFORM

Sender max@http://fanclub-beatrix.royalty-spotters.nl:7239

Receiver elke@iiop://royalty-watcher.uk:5623

Language Prolog

Ontology genealogy

Content female(beatrix),parent(beatrix,juliana,bernhard)

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

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).

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

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).