Download In today lecture we take a closer look at how the different types of

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Distributed operating system wikipedia , lookup

Library (computing) wikipedia , lookup

Unix security wikipedia , lookup

DNIX wikipedia , lookup

Burroughs MCP wikipedia , lookup

Spring (operating system) wikipedia , lookup

Process management (computing) wikipedia , lookup

Thread (computing) wikipedia , lookup

Transcript
In today lecture we take a closer look at how the different types of processes play a
crucial role in distributed systems. The contents we will discuss are:
1. Brief introduction of Thread and Process
2. Typical organization of Clients and servers, object servers
3. Process migration, code migration.
4. Software agents
1. Thread
1.1 Introduction to Threads
A Process is often defined as a program in execution. To execute a program, an
operating system creates a number of virtual processors, each one for running a
different program. To keep track of these virtual processors, the operating system has
a process table, containing entries to store CPU register values, memory maps, open
files, accounting information, privileges, etc.
For creating a process, the OS must create a complete independent address. The price
is high. Even for the switching of the CPU between two processes, because the OS
will have to modify registers of the memory management unit (MMU) and invalidate
address translation caches such as in the translation lookaside buffer (TLB)
A thread is very similar to a process in the sense that it can also be seen as the
execution of a (part of a) program on a virtual processor. A thread context often
consists of nothing more than the CPU context, along with some other information
for thread management.
Thread Usage in Nondistributed Systems
For a single-threaded process, whenever a blocking system call is executed, the
process as a whole is blocked.
Using the multithread process, a program can process more than two tasks at same
time, for example the spreadsheet program. Multithreading also makes it possible to
exploit parallelism when executing the program on a multiprocessor system.
Thread switching can sometimes be done entirely in user space.
Thread Implementation
Two approaches to implement a thread package:
 To construct a thread library that is executed entirely in user mode
Advantages: a. It is cheap to create & destroy threads
b. Switching thread context can be done in just a few instruction.
Drawback: The invocation of a blocking system call will immediately block
the entire process to which the thread belongs, and thus all the
other threads in that process
 To have the kernel be aware of threads and schedule them.
o This approach will circumvent the drawback of the first approach. But
there is a high price to pay. Every thread operation ( creation deletion,
synchronization etc) will have to be carried out by the kernel, requiring
a system call.
Lightweight process (LWP) is the solution to these problems. It lies in a hybrid form
of user-level & kernel-level threads. LWP runs in the context of a single (Heavyweight) process, and there can be several LWPs per process. In addition to having
LWPs, a system also offers a user-level thread package.
The combination of (user-level) threads and LWPs works as follows:
 The thread package has a single routine to schedule the next thread
 When LWP is created, it is given its own stack and is instructed to execute the
scheduling routine in search of a thread to execute
 Thread table is shared by LWPs. Synchronization is realized by mutexes
implemented entirely in user space.
Advantages to using LWPs in combination with user-level thread
 Creating, destroying, and synchronizing threads is relatively cheap and
involves on kernel intervention at all
 A blocking system call will not suspend the entire process, provided that a
process has enough LWPs.
 There is no need for an application to know about the LWPs. All it sees are
user level threads.
 LWPs canbe easily used in multiprocessing environments by executing
different LWPs on different CPUs
Drawback of using LWPs: We still need to create & destroy LWPs, which is just as
expensive as with kernel-level threads.
1.2 Threads in Distributed Systems
Multithreaded Clients
Example: Web browser is doing a number of tasks simultaneously. It is designed as a
multithreaded client program. Each thread sets up a separate connection to the server
and pulls in the data.
Advantages:
 Hiding communication latencies as much as possible by delivering text
contents first, then image and other data.
 Several connections can be opened simultaneously. Web server can be
replicated across multiple machines with multithreaded client. Connections
maybe set up to different replicas, allowing data to be transferred in parallel.
Multithreaded Servers
Here using a file server to explain the using of multithread in server machine.
A multithreaded server organized in a dispatcher/worker model.
Model
Characteristics
Threads
Parallelism, blocking system calls
Single-threaded process
No parallelism, blocking system calls
Finite-state machine
Parallelism, nonblocking system calls
Three ways to construct a server
2 Clients
From now, we begin to take a closer look at the anatomy of clients and servers
2.1 User Interfaces
A major task of most clients is to interact with a human user and a remote server. The
X window system is an example of traditional graphical user interface.
It is important to realize that user-interface systems such as X essentially provide no
more than a graphical interface to applications. The only information that applications
can expect from such systems are events identifying basic user actions that are
directly related to the devices attached to the terminal. Examples of such events are
those regarding keystrokes, mouse position, button operations, etc.
2.2 Client-Side Software for Distribution Transparency
Besides the user interface and other application-related software, client software
comprises components for achieving distribution transparency.
Access transparency is generally handled through the generation of a client stub from
an interface definition of what the server has to offer.
Replication transparency in many distributed systems is handled by means of clientside solution. One way is forward invocation request to each replica and client proxy
collects all responses transparently and passes a single return value to the client
application.
3 SERVERS
3.1 General Design Issues
A server is a process implementing a specific service on behalf of a collection of
clients. It is organized in this way: it waits for an incoming request from a client and
subsequently ensures that the request is taken care of, after which it waits for the next
incoming request.
Issues:

Iterative server: the server itself handles the request and, if necessary, returns
a response to the requesting client.

Concurrent server: it 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. E.g. Multithreaded server, or Unix way: fork a new
process for each new incoming request.

Discuss the endpoint (port) and how to manage it.

Discuss whether and how a server can be interrupted.

Whether or not the server is stateless:
o A stateless server does not keep information on the sate of its clients,
and can change its own state without having to inform any client, e.g.
A Web Server.
o A stateful server does maintain information on its clients, e.g. a file
server that allows a client to keep a local copy of a file.
3.2 Object Servers
An object server is a server tailored to support distributed objects. Compare with
other servers, it does not really provide a specific service. Specific services are
implemented by the objects that reside in the server. The server only provides the
means to invoke local objects.
Alternatives for Invoking Objects
For an object to be invoked, the object server needs to know which code to execute,
on which data it should operate, whether it should start a separate thread to take care
of the invocation, and so on.
Approaches:



Assume all objects look alike and that there is only one way to invoke an
object.
Support different policies: for transient object A. create it at the first
invocation request and destroy it as soon as no client bond to it. B. create all
transient object at the time the server is initialized.
A server could follow the policy that each of its objects is place in a memory
segment of its own. Other approach is to let the object at least share their code.
Object Adapter
An Object adapter can be best thought of as software implementing a specific
activation policy.
Organization of an object server supporting different activation policies
The only issue that is important to an object adapter is that it can extract an object
reference from an invocation request, and subsequently dispatch the request to the
referenced object, but now following a specific activation policy.
Rather than passing the request directly to the object, an adapter hands an invocation
request to the server-side stub of that object.
4. CODE MIGRATION
4.1 Approaches to Code Migration
Reasons for Migrating Code
Code migration in distributed systems took place in the form of process migration.
That reason has always been performance:


The process should be close to where that data reside. A. Migrating parts of
the client to server when doing the database operation. B. Migrating parts of
the server to client in interactive database applications.
Code migration can be used to improve performance by exploiting parallelism.
Models for Code Migration
As in process migration, the execution status of a program, pending signals and other
parts of the environment must be moved as well.
A process consists of three segments according to Fugetta’s framework:
 Code segment is the part that contains the set of instructions that make up the
program that is being executed.
 Resource segment contains references to external resources needed by the
process, such as file, printers, devices, other processes, and so on.
 Execution segment is used to store the current execution state of a process,
consisting of private data, the stack, and the program counter.
Weak mobility model: In this model, it is possible to transfer only the code segment,
along with perhaps some initialization data. Feature: a transferred program is always
started from its initial state, e.g. Java applets.
Strong mobility model: Besides the code segment being transferred, the execution
segment can be transferred as well. Feature: A running process can be stopped,
subsequently moved to another machine, and then resume execution where it left off.
Even for the upper two models, further distinction can be made between senderinitiated and receiver-initiated migration.
In sender-initiated migration, migration is initiated at the machine where the code
currently resides or is being executed.
In receiver-initiated migration, the initiative for code migration is taken by the
target machine
In the case of weak mobility, it also makes a difference if the migrated code is
executed by the target process, or whether a separate process is started, e.g. Java
applets sere executed in the browser’s address space.
For strong mobility model, instead of moving a running process, it can also be
supported by remote cloning.
Alternatives for code migration.
4.2 Migration and Local Resources
Three types of process-to-resource bindings:
 Strongest binding – binding by identifier is when a process refers to a
resource by its identifier.
 Weaker form binding is when only the value of a resource is needed. It is also
called binding by value.
 The weakest form of binding is when a process indicates it needs only a
resource of a specific type. This binding by type is exemplified by references
to local devices, such as monitors, printers, and so on.
Three types of resource to machine bindings:
 Unattached resources
 Fastened resources
 Fixed resources
Resource-to machine binding
process-toresource
bindings
Unattached
Fastened
Fixed
By identifier MV (or GR)
GR (or MV)
GR
By value
CP ( or MV, GR) GR (or CP)
GR
By type
RB (or GR, CP) RB (or GR, CP) RB (or GR)
Actions to be taken with respect to the references to local resources when migrating
code to another machine.