Institution of Technology School of Computing Department of Information Technology
Institution of Technology School of Computing Department of Information Technology
School of Computing
Department of Information Technology
Chapter 2: Processes
May 21, 2021
Semagn Sh.
LESSON PLAN
Instructor Name: Semagn Shifere Date: 05/21/2021G.C
School: Computing Duration: 2:00hr
Department: Information Technology(IT) Period: I Semester: II
Course Title: Introduction to Distributed System Class: 3nd year section 2
Topic: Processes No of Students: 35
Books for Reference: T1 No of hours required: 2:00hr
Teaching Aids
Teaching Methods
PPT and Discussion
2
Objectives
To learn about the process involved in distributed system
communication.
To describe the feature of process and thread in distributed
system.
To differentiate about synchronization and replication process
in distributed system.
Content Outline
Content
2/
Threads Introduction to Threads
Introduction to Threads
Introduction to Threads
We build virtual processors in software, on top of physical
processors:
Processor: Provides a set of instructions along with the capability of automatically
executing a series of those instructions.
Thread:
- A minimal software processor in whose context a series of instructions can
be executed.
- Can be seen as execution of (part of) a program on a virtual processor.
- Analogous to the concept of a procedure that runs independently from
its main program.
- Useful to structure large applications into parts that could logically
be executed at the same time.
Process:
- A software processor in whose context one or more threads may be
executed.
- A program that is currently being executed on one of the OSs
virtual processors.
3/
Threads Introduction to Threads
Introduction to Threads
4/
Threads Introduction to Threads
Advantages of multithreading
No need to block with every system call.
In a single-threaded process, whenever a blocking system call is
executed, the process as a whole is blocked. E.g. a spreadsheet cell will
be unable to process cell-dependent computations while the program is
waiting for input.
Easy to exploit available parallelism in multiprocessors
It becomes possible to exploit parallelism when executing a program on
a multiprocessor system.
Each thread is assigned to a different CPU.
Shared data are stored in shared main memory.
5/
Threads Introduction to Threads
Advantages of multithreading
Cheaper communication between components than with IPC
In stead of using processes, large applications can be constructed such
that different parts are executed by separate threads.
Communication between those parts is dealt with by using shared
data.
Thread switching can sometimes be done entirely in user space.
Software engineering expressive power
From software engineering perspective, many applications are
simply easier to structure as a collection of cooperating threads.
For example, in the case of word processor, separate threads can
be used for handling user input, spelling and grammar checking,
etc.
6/
Threads Thread Implementation
Thread Implementation
Thread Package
Threads are generally provided in the form of a thread
package.
Thread package contains:
Operations to create and destroy threads.
Operations on synchronization variables (mutexes and
conditional variables).
Three approaches to thread package implementation:
User-Level Solution
Kernel-Level Solution
Lightweight Process (LWP) Solution
7/
Threads Threads in Distributed Systems
Multithreaded Servers
An important use
of multithreading
in distributed
systems is at the
server side.
- Starting a thread to handle an incoming request is much cheaper than
Main issues are: a process.
starting
Improving performance
- Exploits parallelism to attain high performance. Single-threaded server
cant take advantage of multiprocessor.
- Hides network latency. Other work can be done while a request is coming
Betterin.structure
- Most servers have high I/O demands. Using simple, well-
understood blocking calls simplifies the overall structure.
- Multithreaded programs tend to be smaller and easier to understand
due to simplified flow of control.
9/
Threads Threads in Distributed Systems
12 /
Clients User Interfaces
User Interfaces
13 /
Clients User Interfaces
In addition to the user interface, parts of the processing and data level in
a client-server application are executed at the client side
18 /
Servers General Organization
General Organization
General Organization
How can the client know this endpoint?
Two approaches
Have a daemon running and listening to a well-known endpoint like in
DCE; it keeps track of all endpoints of services on the collocated
server
The client will first contact the daemon which provides it with
the endpoint, and then the client contacts the specific server
General Organization
Types of Servers
Types of Servers
Iterative vs. Concurrent Server:
Iterative server itself handles only one request at a time whereas
concurrent server passes the request to a separate thread or another
process and waits for another request.
Superservers:
- Servers that listen to several ports, i.e., provide several independent
services.
- When a service request comes in, they start a subprocess to handle
the request.
- For services with more permanent traffic, get a dedicated server.
22 /
Servers Out-of-Band Communication
Out-of-Band Communication
How can a server be interrupted once it has accepted (or is in the process of accepting) a
service request?
For instance, a user may want to interrupt a file transfer, may be it was the wrong file
let the client exit the client application; this will break the connection to the server;
the
server will tear down the connection assuming that the client had crashed
- Server
Solution hasa separate
1: Use a separate
portthread (or process)
for urgent waiting
data (possibly for incoming
per service request):urgent
messages.
- When urgent message comes in, associated request is put on hold.
- Note: we require OS supports high-priority scheduling of specific
threads or processes.
Solution 2: Use out-of-band communication facilities of the transport layer:
- Example, TCP allows to send urgent messages in the same
connection.
- Urgent messages can be caught using OS signaling techniques.
23 /
Servers Servers and State
Stateless Servers
Never keep accurate information about the status of a client after
having handled a request:
Dont record whether a file has been opened (simply close it again
after access)
Dont promise to invalidate a clients cache
Dont keep track of your clients
Consequences:
Clients and servers are completely independent
State inconsistencies due to client or server crashes are reduced
Possible loss of performance because, e.g., a server cannot
anticipate client behavior (think of prefetching file blocks)
24 /
Servers Servers and State
Stateful Servers
Keeps track of the status of its clients:
Record that a file has been opened, so that prefetching can be done
Knows which data a client has cached, and allows clients to keep
local copies of shared data
Server may record clients behavior using cookies
Observation:
The performance of stateful servers can be extremely high,
provided clients are allowed to keep local copies.
Session state vs. permanent state
As it turns out, reliability is not a major problem.
25 /
Servers Server Clusters
Server Clusters
Server cluster is collection of machines connected through a network,
where each machine runs one or more servers.
Many server clusters are organized along three different tiers, to
improve performance.
The first tier is generally responsible for passing requests to
an appropriate server.
The second and the third tiers can be merged.
Server Clusters
Request Handling
Having the first tier handle all communication from/to the cluster
may lead to a bottleneck.
Solution: Various, but one popular one is TCP-handoff:
27 /
Code Migration Approaches to Code Migration
Code migration
28 /
Code Migration Approaches to Code Migration
Execute at
~ target
Sender-initiated
process
/mobility '--........ Execute in
separate process
I
Weak mobility
Execute at
~ Receiver- ~ target process
initiated
'--........ Execute in
mobility
separate process
Mobility
mechanism ~ Migrate process
Sender-initiated
/mobility
'--........ Clone
\
Strong mobility process
~ Migrate process
~ Receiver-initiated
mobility
'--........ Clone
process 32 /
Code Migration Migration and Local Resources
34 /
Code Migration Migration and Local Resources
35 /
Code Migration Migration and Local Resources
Main problem:
The target machine may not be suitable to execute the migrated code.
The definition of process/thread/processor context is highly dependent
on local hardware, operating system and runtime system.
Solution
Make use of an abstract machine that is implemented on
different platforms.
- Interpreted languages running on a virtual machine E.g., Java/JVM,
scripting languages
37 /
Code Migration Migration in Heterogeneous Systems
Any Question?
38 /
Code Migration Migration in Heterogeneous Systems
Quiz 1
4
Difference between iterative and concurrent server?
5
How can a server be interrupted once it has accepted a
service request?
6
Difference between state full and stateless server ?
Why code migration is useful?
39 /