Chapter 3
Chapter 3
1
INTRODUCTION
The concept of a process originates from the field of OS.
process is a program in execution.
From OS perspective, the management and scheduling of
processes are the most important issue.
other important issues arise in distributed systems;
multithreading;
to efficiently organize client-server systems;
processing.
virtualization:
allows an application and its environment to run concurrently
(a) (b)
Fig.3.1. (a) three processes each with one thread. 5
Fig.3.2. Threads
CONT…
10
LIGHTWEIGHT PROCESSES (LWP)
a LWP runs in the context of a single (heavy-weight)
process, and there can be several LWPs per process.
11
CONT…
the thread package can be shared by multiple LWPs,
as shown in the figure 3.4.
this means that each LWP can be running its own (user-
level) thread
application
Drawback:
need to create and destroy LWPs, which is just as expensive
as with kernel-level threads. 13
3.1.2. THREADS IN DISTRIBUTED SYSTEMS
threads allow blocking system calls without blocking
the entire process;
this means multiple logical connections (communications)
can be established at the same time.
14
CONT…
Multithreaded Clients:
the main advantage is hide communication latency.
addresses delays in downloading documents from web servers
in a WAN.
The usual way to hide communication latencies is to
initiate communication and immediately proceed
with something else.
Example: consider web browsers:
fetching different parts of a page can be implemented as a
separate thread
each opening its own TCP connection to the server
each can display the results as it gets its part of the page
15
CONT…
Hide latency by starting several threads
One to download text (display as it arrives)
Others to download photographs, figures, etc.
16
CONT…
Multithreaded Servers:
servers can be constructed in three ways:
A. Single-threaded process
it processes one request at a time
it gets a request, examines it, carries it out to completion
before getting the next request
while waiting for the disk, the server is idle and does not
process any other requests;
consequently, requests from other clients cannot be
handled
17
CONT…
B. Threads: (Multi-threaded)
threads are more important for implementing servers
18
CONT…
C. Finite-state machine
if threads are not available
it gets a request, examines it, tries to fulfill the request
from cache, else sends a request to the file system;
but instead of blocking it records the state of the current
request and proceeds to the next request
but hard to program
Summary
19
3.2. ANATOMY OF CLIENT
A. (Networked) User Interfaces:
A major task of client machines is to provide the means
for users to interact with remote servers.
Fig 3.6.
a networked application with its own a general solution to allow access to
protocol remote applications
23
Fig 3.7., Transparent replication of a server using a client-side solution
3.3. ANATOMY OF SERVERS
3.3.1. General Design Issues
a server is a process implementing a specific service
on behalf of a collection of clients.
each server is organized in the same way; it waits until a
request arrives.
A. How to organize servers?
iterative server:
the server itself handles the request and, if necessary, returns
a response to the requesting client.
concurrent server:
a concurrent server does not handle the request itself, but
passes it to a separate thread or another process, after
which it immediately waits for the next incoming request.
24
a multithreaded server is an example of a concurrent server
CONT…
B. Where do clients contact a server?
clients send requests to an end point, also called a
port, at the machine where the server is running.
Each server listens to a specific end point.
Well-known ports:
assigned and controlled by IANA for standard services,
Registered ports:
are not assigned and controlled by IANA;
with the endpoint, and then the client contacts the specific
server
27
32
Fig. 3.10. The general organization of a three-tiered server cluster
CONT…
Distributed Servers
the problem with a server cluster is when the logical
switch (single access point) fails making the
cluster unavailable.
to eliminate this potential problem, several access
points can be provided where the addresses are
publicly available leading to a distributed server.
For example, the Domain Name System (DNS) can
return several addresses, all belonging to the same host
name.
33
3.4. CODE MIGRATION
So far, we have been mainly concerned with distributed
systems in which communication is limited to passing
data.
However, there are situations in which passing programs,
even while they are running, and also in heterogeneous
systems; simplifies the design of a distributed system.
37
3.4.1. MODELS FOR CODE MIGRATION
communication in distributed systems is concerned
with exchanging data between processes.
code migration deals with moving programs
between machines, with the intention to have those
programs be executed at the target.
in some cases, as in process migration, the execution
status of a program, pending signals, and other parts of
the environment must be moved as well.
1. Weak Mobility
transfer only the code segment and may be some
initialization data;
process can only migrate before it begins to run, or
perhaps at a few intermediate points.
the feature of weak mobility is that a transferred
program is always started from its initial stage.
e.g. Java Applet (which always start execution from the
beginning)
The benefit of this approach is its simplicity.
it requires only that the target machine can execute that code.
40
CONT…
In case of week mobility, the migrated code is executed
by the target process (in its own address space) or a
separate process.
For example:
Java applets are simply downloaded by a web browser and
are executed in the browser's address space.
Advantage:
no need to start a separate process, thereby avoiding
communication at the target machine.
Drawback:
the target process needs to be protected against malicious or
inadvertent code executions.
a simple solution is to let the operating system take care of
that by creating a separate process to execute the migrated41
code.
CONT…
2. Strong Mobility
transfer code segment and execution segment.
processes can migrate after they have already started
to execute.
its feature is that a running process can be stopped,
subsequently moved to another machine, and then
resume execution where it is stopped.
it is much harder to implement
can also be supported by remote cloning; having an
exact copy of the original process and running on a
different machine.
the cloned process is executed in parallel to the original
process.
42
UNIX does this by forking a child process and letting
that child continue on a remote machine.
CONT…
43
CONT…
Receiver-initiated:
the initiative for code migration is taken by the target
machine.
Example: Java applets.
code migration occurs between a client and a server,
where the client takes the initiative for migration.
the server is generally not interested in the client's
resources. Instead, code migration to the client is done
only for improving client-side performance.
44
Summery for models of code migration
45
Fig. 3.12. Alternatives for code migration
3.4.2. MIGRATION AND LOCAL RESOURCES
So far, only the migration of the code and execution
segment has been taken into account.
50
CONT…
when a process is bound to a resource by value:
when the resource is fixed:
occurs when a process assumes that memory can be shared
between processes.
establishing a global reference (means need to implement a
52
3.4.3. MIGRATION IN HETEROGENEOUS SYSTEMS
So far, we have assumed that the migrated code can be
easily executed at the target machine when dealing with
homogeneous systems.
However, distributed systems are constructed on a
heterogeneous collection of platforms, each with its
own OS and machine architecture.
Migration in such systems requires:
each platform is supported, i.e. the code segment can be
executed on each platform.
the execution segment can be properly represented at each
platform.
Heterogeneity problems are similar to those of portability.
53
CONT…
heterogeneity can be addressed by providing process
virtual machines:
for scripting languages directly interpret the migrated code
at the host site.
for Java interpret intermediate code generated by a compiler
55
END
56