ds3 Pro
ds3 Pro
ds3 Pro
Processes
Chapter 3
1
Course/Slides Credits
Note: all course presentations are based on those
developed by Andrew S. Tanenbaum and
Maarten van Steen. They accompany their
"Distributed Systems: Principles and
Paradigms" textbook (1st & 2nd editions).
http://www.prenhall.com/divisions/esm/app/aut
hor_tanenbaum/custom/dist_sys_1e/index.html
And additions made by Paul Barry in course
CW046-4: Distributed Systems
http://glasnost.itcarlow.ie/~barryp/net4.html
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 and virtualization within clients/servers
2. Process and code migration
3. Software agents
3
Introduction to Threads
• Modern OSs provide “virtual processors”
within which programs execute.
• A programs execution environment is
documented 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.
4 • The solution: Threading.
Problems with Processes
• Creating and managing processes is generally
regarded as an expensive task (fork system call).
• Making sure all the processes peacefully co-exist on
the system is not easy (as concurrency transparency
comes at a price).
• Threads can be thought of as an “execution of a part
of a program (in user-space)”.
• Rather than make the OS responsible for concurrency
transparency, it is left to the individual application to
manage the creation and scheduling of each thread.
5
Important Implications
• 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).
• Additionally, the assumption is that the
development environment provides a
Threads Library for developers to use
(most modern environments do).
6
Thread Usage 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
Threads in Distributed Systems
• Important characteristic: a blocking call in a
thread does not result in the entire process
being blocked.
• This 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
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
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
Multithreaded Servers (1)
16
Architectures of Virtual Machines (2)
• An interface consisting of system calls
as offered by an operating system.
• An interface consisting of library calls
– generally forming what is known as an
Application Programming Interface
(API).
– In many cases, the aforementioned
system calls are hidden by an API.
17
Architectures of Virtual Machines (3)
20
Architectures of Virtual Machines (5)
25
Networked User Interfaces (1)
31
The basic organization of the X Window System
Client-Side Software for
Distribution Transparency
36
General Design Issues (1)
39
Object Adapter
49
Reasons for Migrating Code
50
Example of Process Migration
51
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 (using
JavaScript) on Web forms is a good example of
this type of processing. Error-check the data
52
close to the user, not at the server.
Classic” Code Migration Example“
53
Another Big Advantage: Flexibility
55
Code Migration Models
56
Migration in Heterogeneous Systems
• Three ways to handle migration (which can be
combined):
1. Pushing memory pages to the new machine and
resending the ones that are later modified during the
migration process.
2. Stopping the current virtual machine; migrate
memory, and start the new virtual machine.
3. Letting the new virtual machine pull in new pages as
needed, that is, let processes start on the new virtual
machine immediately and copy memory pages on
57 demand.
Code Migration Characteristics
59
?How Does the Migrated Code Run
• Another issue surrounds where the migrated
code executes:
1. Within an existing process (possibly as a thread)
2. 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.
60
Models for Code Migration
62
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
(e.g., a printer).
63
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 following diagram for a good
summary of resource-to-binding
characteristics (to find out what to do with
which resource when).
64
Migration and Local Resources
3-15
Description Status
Return codes, error codes, error strings, etc. Global system variables
Stack of activation records, one for each running command Stack of call frames
71
Types of Software Agents
1. Collaborative Agent – also known as “multi-agent
systems”, which can work together to achieve a
common goal (e.g., planning a meeting).
2. Mobile Agent – code that can relocate and continue
executing on a remote machine.
3. Interface Agent – software with “learning abilities”
(that damned MS paperclip, and the ill-fated “bob”).
4. Information Agent – agents that are designed to
collect and process geographically dispersed data
and information.
72
Software Agents in Distributed Systems
Common to
Description Property
all agents?
Can exchange information with users and other agents Yes Communicative
Examples of different message types in the FIPA ACL [ FIPA 1998], giving the
purpose of a message, along with the description of the actual message content.
76
Agent Communication Languages (2)
Value Field
INFORM Purpose
max@http://fanclub-beatrix.royalty-spotters.nl:7239 Sender
elke@iiop://royalty-watcher.uk:5623 Receiver
Prolog Language
genealogy Ontology
female(beatrix),parent(beatrix,juliana,bernhard) Content
A simple example of a FIPA ACL message sent between two agents using
77 Prolog to express genealogy information.