ASSOSA UNIVERSITY
COLLAGE OF COMPUTING AND INFORMATCS
DEPARTMENT OF COMPUTER SCINCE
DISTRIBUTED SYSTEM INDIVIDUAL ASSIGNMENTS
Name ID
1,Lemi Turo …………………………………RU/2465/12
Submitted to: Gebreigziabher A.
Submission date 15/05/2023
Assosa, Ethiopia
Contents
Part I .............................................................................................................................................................. 4
Distinguish between Process and Thread? ................................................................................................... 4
Why Threads over Processes? Write Advantages. ....................................................................................... 6
List Thread examples in both Non-DS and DS............................................................................................... 6
What is Multithreading? Explain with Example. ........................................................................................... 7
Explain the approaches for Thread Implementation. ................................................................................... 7
Explain the ways in which servers can be constructed. ................................................................................ 8
Explain the two issues in anatomy of clients. ............................................................................................... 8
How to organize Servers? ............................................................................................................................. 9
Where do Clients contact Servers? Explain. ................................................................................................. 9
Part II ............................................................................................................................................................. 9
What is Code Migration? ............................................................................................................................ 10
Why Code Migration? Reasons for Migrating Codes? ................................................................................ 10
List available Models for Code Migration. .................................................................................................. 11
Differentiate between Weak Mobility Vs. Strong Mobility? ...................................................................... 13
Differentiate between Senders Initiated Vs. Receiver Initiated? ............................................................... 13
Explain Types of Process-to-Resource Bindings.......................................................................................... 14
Explain Types of Resource-to-Machine Bindings. ....................................................................................... 14
References .................................................................................................................................................. 15
Page | 2
1. Distinguish between Process and Thread?
2. Why Threads over Processes? Write Advantages.
3. List Thread examples in both Non-DS and DS.
4. What is Multithreading? Explain with Example.
5. Explain the approaches for Thread Implementation.
6. Explain the ways in which servers can be constructed.
7. Explain the two issues in anatomy of clients.
8. How to organize Servers? Iterative Vs. Concurrent?
9. Where do Clients contact Servers? Explain.
Part II - Questions on Process (5%)
1. What is Code Migration?
2. Why Code Migration? Reasons for Migrating Codes?
3. List available Models for Code Migration.
4. Differentiate between Weak Mobility Vs. Strong Mobility?
5. Differentiate between Senders Initiated Vs. Receiver Initiated?
6. Explain Types of Process-to-Resource Bindings.
7. Explain Types of Resource-to-Machine Bindings
Page | 3
Part I
Distinguish between Process and Thread?
What is a Process?
A process is the execution of a program that allows you to perform the appropriate actions
specified in a program. It can be defined as an execution unit where a program runs. The OS
helps you to create, schedule, and terminates the processes which is used by CPU. The other
processes created by the main process are called child process.
A process operations can be easily controlled with the help of PCB (Process Control Block). You
can consider it as the brain of the process, which contains all the crucial information related to
processing like process id, priority, state, and contents CPU register, etc.
What is Thread?
Thread is an execution unit that is part of a process. A process can have multiple threads, all
executing at the same time. It is a unit of execution in concurrent programming. A thread is
lightweight and can be managed independently by a scheduler. It helps you to improve the
application performance using parallelism.
Multiple threads share information like data, code, files, etc. We can implement threads in three
different ways:
1. Kernel-level threads
2. User-level threads
3. Hybrid threads
Properties of Process
Here are the important properties of the process:
Creation of each process requires separate system calls for each process.
It is an isolated execution entity and does not share data and information.
Processes use the IPC(Inter-Process Communication) mechanism for communication that
significantly increases the number of system calls.
Process management takes more system calls.
A process has its stack, heap memory with memory, and data map.
Properties of Thread
Here are important properties of Thread:
Single system call can create more than one thread
Page | 4
Threads share data and information.
Threads shares instruction, global, and heap regions. However, it has its register and
stack.
Thread management consumes very few, or no system calls because of communication
between threads that can be achieved using shared memory.
Difference between Process and Thread
Here, are the important differences between Process and Thread
Parameter Process Thread
Definition Process means a program is in execution. Thread means a segment of a process
Lightweight The process is not Lightweight. Threads are Lightweight.
Termination time The process takes more time to terminate. The thread takes less time to termina
Creation time It takes more time for creation. It takes less time for creation.
Communication between processes needs more time Communication between threads requ
Communication
compared to thread. compared to processes.
Context switching
It takes more time for context switching. It takes less time for context switchin
time
Resource Process consume more resources. Thread consume fewer resources.
All the level peer threads are treated
Treatment by OS Different process are tread separately by OS.
OS.
Memory The process is mostly isolated. Threads share memory.
Sharing It does not share data Threads share data with each other.
Page | 5
Why Threads over Processes? Write Advantages.
Processes require more time for context switching as they are heavier. Threads require less time
for context switching as they are lighter than processes. Processes are totally independent and
don't share memory. A thread may share some memory with its peer threads
On a multiprocessor system, multiple threads can concurrently run on multiple CPUs. Therefore,
multithreaded programs can run much faster than on a uniprocessor system. They can also be
faster than a program using multiple processes, because threads require fewer resources and
generate less overhead.
Advantages of Thread:
Threads minimize the context switching time.
Use of threads provides concurrency within a process.
Efficient communication.
It is more economical to create and context switch threads.
Threads allow utilization of multiprocessor architectures to a greater scale and efficiency.
List Thread examples in both Non-DS and DS.
Non-distributed system:
Multi-threaded Web Server: A web server can use threads to handle multiple client
requests simultaneously.
Video Game: A video game can use threads to manage different aspects of the game,
such as graphics rendering, physics simulation, and AI.
Image Processing: An image processing program can use threads to apply filters to
images.
Distributed system:
Distributed File System: A distributed file system can use threads to manage file access
across multiple machines.
Distributed Database: A distributed database can use threads to manage database
requests across multiple machines.
Page | 6
Map Reduce: Map Reduce is a programming model used for distributed computing. It
uses threads to process large amounts of data across multiple machines.
What is Multithreading? Explain with Example.
Multithreading is the ability of a program or an operating system to enable more than one user
at a time without requiring multiple copies of the program running on the computer.
Multithreading can also handle multiple requests from the same user.
Multithreading enables us to run multiple threads concurrently. For example in a web browser,
we can have one thread which handles the user interface, and in parallel we can have another
thread which fetches the data to be displayed. So multithreading improves the responsiveness of
a system.
An example of multithreading
Multithreading is used in many different contexts. One example occurs when data is entered into
a spreadsheet and used for a real-time application.
When working on a spreadsheet, a user enters data into a cell, and the following may happen:
column widths may be adjusted;
repeating cell elements may be replicated; and
Spreadsheets may be saved multiple times as the file is further developed.
Each activity occurs because multiple threads are generated and processed for each activity
without slowing down the overall spreadsheet application operation.
Playing a video and downloading it at the same time is an example of multithreading.
Explain the approaches for Thread Implementation.
There are two ways of implementing a thread package:
1. In user space
Page | 7
2. In kernel
Threads implementation in the user space
In this model of implementation,
The threads package entirely in user space, the kernel has no idea about it.
A user-level threads package can be executed on an operating system that doesn't support
threads and this is the main advantage of this implementation model i.e. Threads package
in user space.
Threads implementation in the kernel
In this method of implementation model:
The threads package completely in the kernel.
There is no need for any runtime system.
To maintain the record of all threads in the system a kernel has a thread table.
A call to the kernel is made whenever there is a need to create a new thread or destroy an
existing thread. In this, the kernel thread table is updated.
Explain the ways in which servers can be constructed.
Prepare. Before you begin, document your network.
Install your server. If your server came with an operating system preinstalled, you can
connect it to the network and begin configuration.
Configure your server.
Complete the setup.
Explain the two issues in anatomy of clients.
Client middleware can be configured to repeatedly attempt to connect to a server, or perhaps try
another server after several attempts.
Concurrency transparency can be handled through special intermediate servers, notably
transaction monitors, and requires less support from client software.
Likewise, persistence transparency is often completely handled at the server.
Page | 8
How to organize Servers?
A server is a process implementing a specific service on behalf of a collection of clients.
In essence, each server is organized in the same 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.
Iterative Vs. Concurrent?
There are several ways to organize servers.
An iterative server, the server itself handles the request and, if necessary, returns a
response to the requesting client.
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.
A multithreaded server is an example of a concurrent server. An alternative
implementation of a concurrent server is to fork a new process for each new incoming
request. This approach is followed in many UNIX systems.
The thread or process that handles the request is responsible for returning a response to
the requesting client
Where do Clients contact Servers? Explain.
In all cases, 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.
How do clients know the end point of a service?
One approach is to globally assign end points for well-known services. For example,
servers that handle Internet FTP requests always listen to TCP port 21.
Likewise, an HTTP server for the World Wide Web will always listen to TCP port 80.
These end points have been assigned by the Internet Assigned Numbers Authority
(lANA), and are documented in Reynolds and Postel (1994).
With assigned end points, the client only needs to find the network address of the
machine where the server is running.
Part II - Questions on Process
Page | 9
What is Code Migration?
Code Migration in distributed systems took place in the form of process migration in which
an entire process was moved from one machine to another.
Moving a running process to a different machine is a costly and intricate task, and there had
better be a good reason for doing so.
Code migration is the movement of programming code from one system to another. There
are three distinct levels of code migration with increasing complexity, cost and risk.
Load is often expressed in terms of the CPU queue length or CPU utilization, but other
performance indicators are used as well.
Load distribution algorithms by which decisions are made concerning the allocation and
redistribution of tasks with respect to a set of processors, play an important role in compute-
intensive systems.
Why Code Migration? Reasons for Migrating Codes?
Due to the heterogeneity of the underlying platforms and computer networks, performance
improvement through code migration is often based on qualitative reasoning instead of
mathematical mode.
The basic idea is that overall system performance can be improved if processes are moved
from heavily-loaded to lightly-loaded machines.
Besides improving performance, there are other reasons for supporting code migration as
well. The most important one is that of flexibility. The traditional approach to building
distributed applications is to partition the application into different parts, and decide in
advance where each part should be executed.
This same reason can be used for migrating parts of the server to the client. For example, in
many interactive database applications, clients need to fill in forms that are subsequently
translated into a series of database operations.
Reduce Network Bandwidth
Migrate part of server application to client
Page | 10
Migrate part of database server to client to process forms on client side
Reduces database operations over the network
XSS - JavaScript
Parallelism
Mobile Agent
Dynamic Configuration of Distributed Systems
Download and Initialize Code
Why?
Load balancing
Minimizing communication
Optimizing perceived performance
Improving scalability, Flexibility through dynamic configurability
Improving fault tolerance
List available Models for Code Migration.
Code Migration Framework
A Process consists of three segments.
The code segment is the part that contains the set of instructions that make up the program that
is being executed.
Set of instructions being executed.
The resource segment contains references to external resources needed. By the process, such as
files, printers, devices, other processes, and so on. Finally, an execution segment is used to store
the current execution state of a process, consisting of private data, the stack, and, of course, the
program counter.
References to external resources,Files, printers, devices, et cetera
Page | 11
Weak mobility
In this model, it is possible to transfer only the code segment, along with perhaps some
initialization data. A characteristic feature of weak mobility is that a transferred program is
always started from one of several predefined starting position. The benefit of this approach is its
simplicity. Weak mobility requires only that the target machine can execute that code, which
essentially boils down to making the code portable.
Strong Mobility
The execution segment can be transferred as well. The characteristic feature of strong mobility is
that a running process can be stopped, subsequently moved to another machine, and then resume
execution where it left off. Irrespective of whether mobility is weak or strong, a further
distinction can be made between sender-initiated and receiver-initiated migration. Clearly,
strong mobility is much more general than weak mobility, but also much harder to implement.
Sender Initiated Migration
In sender initiated migration, migration is initiated at the machine where the code currently
resides or is being executed. Typically, sender-initiated migration is done when uploading
programs to a compute server. Another example is sending a search program across the Internet
to a Web database server to perform the queries at that server.
Receiver-Initiated Migration
In receiver-initiated migration, the initiative for code migration is taken by the target machine.
Receiver-initiated migration is simpler than sender-initiated migration. In many cases, code
migration occurs between a client and a server, where the client takes the initiative for migration.
Protecting such resources is essential. In contrast, downloading code as in the receiver-initiated
case, can often be done anonymously. Moreover, 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. To that end, only a limited number of resources need to be protected, such as
memory and network. Code migration occurs between a client and a server, where the client
takes the initiative for migration.
Page | 12
Differentiate between Weak Mobility Vs. Strong Mobility?
Weak vs strong mobility
Weak mobility: only code segment + initialization data migrated, e.g. Java applets
Strong mobility: code segment + execution segment.
Weak mobility is the ability of a mobile agent system to allow the migration of the code of an
agent without the complete execution and to restart the execution of such an agent through some
initialization data.
Differentiate between Senders Initiated Vs. Receiver Initiated?
In Sender Initiated migration, migration is initiated at the machine where the code currently
resides or is being executed.
Sender-Initiated migration is done when uploading programs to a compute server. Another
example is sending a search program across the Internet to a Web database server to perform the
queries at that server.
Sender-initiated migration
Migration is initiated where the code resides / is being currently executed
Examples: search-bots, mobile agents Servers should know clients, and ensure security of
resources.
→ More complex interaction scheme.
In Receiver-Initiated migration, the initiative for code migration is taken by the target machine.
Java applets are an example of this approach.
Receiver-Initiated migration is simpler than sender-initiated migration. Securely uploading code
to a server, as is done in sender-initiated migration, often requires that the client has previously
been registered and authenticated at that server. In contrast, downloading code as in the receiver-
initiated case can often be done anonymously.
Receiver -initiated migration
Page | 13
Migration is initiated by the target machine, requiring a new behavior to be added
Examples: Java Applets, JavaScript chunks
Just a few resources on clients need to be secured
Clients may also be anonymous
→ Less complex interaction scheme.
Explain Types of Process-to-Resource Bindings.
Process-to-resource binding
Binding by identifier Need of a resource with a given name – e.g., via an URL, or a local ID
Binding by value Need of a resource based on its value – e.g., code libraries
Binding by type Need of a resource based on its type – typically, local devices like printers,
monitors.
The strongest binding is when a process refers to a resource by its identifier. In that case, the
process requires precisely the referenced resource, and nothing else. An example of such a
binding by identifier is when a process uses a URL to refer to a specific Web site or when it
refers to an FTP server by means of that server’s Internet address. In the same line of reasoning,
references to local communication endpoints also lead to a binding by identifier.
Explain Types of Resource-to-Machine Bindings.
Unattached Resources:- these are generally data files that have been opened by the
process for read / write operation. These resources can be moved easily and quickly to
another machine but they need be referenced properly in the new system so that process
can access the path of the files correctly.
Fastened Resources: - these are generally local Databases on machine A that are used by
the process, now moving these resources to new machine B is possible but quite a
gruelling task. Thus it is preferable to create global references for such resources that can
be accessed over network.
Page | 14
Fixed Resources:- are like switches or hardware devices which can’t be moved. For
these generally global referencing technique is used. For example, open socket
connections can be accessed through tunnelling.
References
1. S. Tanenbaum and Maarten Van Steen.
2. [Link]
Tanenbaum/dp/153028175X
3. Distributed Systems: Principles and Paradigms, 2nd Ed.
4. [Link]
Page | 15