1|181243107004 Distributed Operating System
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL
DISTRIBUTED OPERATING SYSTEM (2160710)
PANCHAL ANKITABEN RAMESHBHAI
ENROLLMENT NO: 181243107004
2|181243107004 Distributed Operating System
Q1-a) Parallel system is the subset of Distributed system. State and justify
that given statement is True or False.
→FALSE – Its False because, In parallel computing multiple processors performs multiple
tasks assigned to them simultaneously. Memory in parallel systems can either be shared or
distributed. Parallel computing provides concurrency and saves time and money.
Parallel computing is a term usually used in the area of High Performance Computing (HPC).
It specifically refers to performing calculations or simulations using multiple processors.
Supercomputers are designed to perform parallel computation. These system do not necessarily
have shared memory (as incorrectly claimed by other answers). OpenMP a tool used in the
space will work on a single machine or clusters of machines found in supercomputers.
Q1-b) Explain Workstation with server model for building distributed
computing system.
In the Workstation-Server Model the distributed system is composed of a network of
workstations where each workstation provides local processing capability and an interface to
the network. The model associates a workstation with each user of the system from which local
and/or remote processing can be initiated. Some workstations may be assigned dedicated roles
as file servers, print servers, time servers, name servers or secure authentication servers.
Workstations may be diskless, depending only on the communication interface and the
operating server nodes to obtain various system services.
In the Workstation-Server Model, idle workstations can be used to improve performance by
sending them work which can be done in parallel with other activities.
Diskless workstations have many advantages. They are cheap, quiet and easy to maintain.
Backing up the disks on a single file server is simpler than backing up a collection of individual
3|181243107004 Distributed Operating System
disks. It also means the file system on every workstation looks the same for each user when
they log on, which facilitates user mobility.
Q2-a) What is Transparency in DOS? Explain any two in detail.
Transparency :-
A transparency is some aspect of the distributed system that is hidden from the user
(programmer, system developer, user or application program). A transparency is provided by
including some set of mechanisms in the distributed system at a layer below the interface where
the transparency is required. A number of basic transparencies have been defined for a
distributed system. It is important to realize that not all of these are appropriate for every
system, or are available at the same level of interface.
The transparencies are :-
Access Transparency :- There should be no apparent difference between local and remote
access methods. In other words, explicit communication may be hidden. For instance, from a
user's point of view, access to a remote service such as a printer should be identical with access
to a local printer. From a programmers point of view, the access method to a remote object
may be identical to access a local object of the same class.
Location Transparency :- The details of the topology of the system should be of no concern to
the user. The location of an object in the system may not be visible to the user or programmer.
This differs from access transparency in that both the naming and access methods may be the
same. Names may give no hint as to location.
Concurrency Transparency :- Users and Applications should be able to access shared data or
objects without interference between each other. This requires very complex mechanisms in a
distributed system, since there exists true concurrency rather than the simulated concurrency
of a central system. For example, a distributed printing service must provide the same atomic
access per file as a central system so that printout is not randomly interleaved.
Replication Transparency :- If the system provides replication (for availability or performance
reasons) it should not concern the user. As for all transparencies, we include the applications
programmer as a user.
Q2-b) What is thread? Explain different models for organizing the thread in
brief.
Thread :-
A thread is a flow of execution through the process code, with its own program counter that
keeps track of which instruction to execute next, system registers which hold its current
working variables, and a stack which contains the execution history.
A thread shares with its peer threads few information like code segment, data segment and
open files. When one thread alters a code segment memory item, all other threads see that.
4|181243107004 Distributed Operating System
A thread is also called a lightweight process. Threads provide a way to improve application
performance through parallelism. Threads represent a software approach to improving
performance of operating system by reducing the overhead thread is equivalent to a classical
process.
Models for organizing thread :-
Dispatcher Worker model :-
~ In this model, the process consists of a single dispatcher thread and multiple worker threads.
~ The dispatcher thread accepts requests from clients and, after examining the request,
dispatches the request to one of the free worker threads for further processing of the request.
~ Each worker thread works on a different client request.
~ Therefore, multiple client requests can be processed in parallel.
Team model :-
~ In this model, all threads behave as equal.
~ Each threads gets and processes clients requests on its own.
~ This model is often used for implementing specialized threads within a process.
~ Each thread of the process is specialized in servicing a specific type of request.
5|181243107004 Distributed Operating System
Pipeline model :-
~ This model is useful for applications based on the producer-consumer model.
~ The output data generated by one part of the application is used as input for another part of
the application.
~ In this model, the threads of a process are organized as a pipeline so that the output data
generated by the first thread is used for processing by the second thread, the output of the
second thread is used for processing by the third thread, and so on.
~ The output of the last thread in the pipeline is the final output of the process to which the
threads belong.
Q2-c) Explain Deadlock and conditions to occur deadlock. Explain any one
deadlock prevention mechanism.
Deadlock is a situation where a set of processes are blocked because each process is holding a
resource and waiting for another resource acquired by some other process.
Consider an example when two trains are coming toward each other on same track and there is
only one track, none of the trains can move once they are in front of each other. Similar situation
occurs in operating systems when there are two or more processes hold some resources and
wait for resources held by other(s). For example, in the below diagram, Process 1 is holding
Resource 1 and waiting for resource 2 which is acquired by process 2, and process 2 is waiting
6|181243107004 Distributed Operating System
for
resource 1 Deadlock can arise if following four conditions hold simultaneously (Necessary
Conditions)
Mutual Exclusion: One or more than one resource are non-sharable (Only one process can use
at a time)
Hold and Wait: A process is holding at least one resource and waiting for resources.
No Preemption: A resource cannot be taken from a process unless the process releases the
resource.
Circular Wait: A set of processes are waiting for each other in circular form.
Deadlock prevention mechanism :-
By Eliminate Hold and wait :-
1. Allocate all required resources to the process before the start of its execution, this way
hold and wait condition is eliminated but it will lead to low device utilization. for
example, if a process requires printer at a later time and we have allocated printer before
the start of its execution printer will remain blocked till it has completed its execution.
2. The process will make a new request for resources after releasing the current set of
resources. This solution may lead to starvation.
7|181243107004 Distributed Operating System
By Eliminate Circular Wait :-
Each resource will be assigned with a numerical number. A process can request the resources
increasing/decreasing. order of numbering.
For Example, if P1 process is allocated R5 resources, now next time if P1 ask for R4, R3 lesser
than R5 such request will not be granted, only request for resources more than R5 will be
granted.
OR Q2-c) Explain Mutual Exclusion using distributed algorithm in DOS.
Lamport’s Distributed Mutual Exclusion Algorithm is a permission based algorithm
proposed by Lamport as an illustration of his synchronization scheme for distributed systems.
In permission based timestamp is used to order critical section requests and to resolve any
conflict between requests.
In Lamport’s Algorithm critical section requests are executed in the increasing order of
timestamps i.e a request with smaller timestamp will be given permission to execute critical
section first than a request with larger timestamp.
In this algorithm :-
• Three type of messages ( REQUEST, REPLY and RELEASE) are used and
communication channels are assumed to follow FIFO order.
• A site send a REQUEST message to all other site to get their permission to enter critical
section.
• A site send a REPLY message to requesting site to give its permission to enter the critical
section.
• A site send a RELEASE message to all other site upon exiting the critical section.
8|181243107004 Distributed Operating System
• Every site Si, keeps a queue to store critical section requests ordered by their timestamps.
request_queuei denotes the queue of site Si
• A timestamp is given to each critical section request using Lamport’s logical clock.
• Timestamp is used to determine priority of critical section requests. Smaller timestamp
gets high priority over larger timestamp. The execution of critical section request is
always in the order of their timestamp.
Algorithm:
• To enter Critical section:
• When a site Si wants to enter the critical section, it sends a request
message Request(tsi, i) to all other sites and places the request on request_queuei.
Here, Tsi denotes the timestamp of Site Si
• When a site Sj receives the request message REQUEST(tsi, i) from site Si, it returns
a timestamped REPLY message to site Si and places the request of site
Si on request_queuej
• To execute the critical section:
• A site Si can enter the critical section if it has received the message with timestamp
larger than (tsi, i) from all other sites and its own request is at the top
of request_queuei
• To release the critical section:
• When a site Si exits the critical section, it removes its own request from the top of
its request queue and sends a timestamped RELEASE message to all other sites
• When a site Sj receives the timestamped RELEASE message from site Si, it
removes the request of Si from its request queue
Q3-a) Explain Wait-die Deadlock prevention.
Wait-Die Scheme –
In this scheme, If a transaction request for a resource that is locked by other transaction, then
the DBMS simply checks the timestamp of both transactions and allows the older transaction
to wait until the resource is available for execution.
Suppose, there are two transactions T1 and T2 and Let timestamp of any transaction T be TS
(T). Now, If there is a lock on T2 by some other transaction and T1 is requesting for resources
held by T2, then DBMS performs following actions:
Checks if TS (T1) < TS (T2) – if T1 is the older transaction and T2 has held some resource,
then it allows T1 to wait until resource is available for execution. That means if a younger
transaction has locked some resource and older transaction is waiting for it, then older
transaction is allowed wait for it till it is available. If T1 is older transaction and has held some
resource with it and if T2 is waiting for it, then T2 is killed and restarted latter with random
delay but with the same timestamp. i.e. if the older transaction has held some resource and
younger transaction waits for the resource, then younger transaction is killed and restarted with
very minute delay with same timestamp. This scheme allows the older transaction to wait but
kills the younger one.
9|181243107004 Distributed Operating System
Q3-b) Explain Design issues in distributed operating system.
Design issues of distributed system: -
Heterogeneity: Heterogeneity is applied to the network, computer hardware, operating system
and implementation of different developers. A key component of the heterogeneous distributed
system client-server environment is middleware. Middleware is a set of service that enables
application and end-user to interacts with each other across a heterogeneous distributed system.
Openness: The openness of the distributed system is determined primarily by the degree to
which new resource sharing services can be made available to the users. Open systems are
characterized by the fact that their key interfaces are published. It is based on a uniform
communication mechanism and published interface for access to shared resources. It can be
constructed from heterogeneous hardware and software.
Scalability: Scalability of the system should remain efficient even with a significant increase
in the number of users and resources connected.
Security: Security of information system has three components Confidentially, integrity and
availability. Encryption protects shared resources, keeps sensitive information secrets when
transmitted.
Failure Handling: When some faults occur in hardware and the software program, it may
produce incorrect results or they may stop before they have completed the intended
computation so corrective measures should to implemented to handle this case.
Failure handling is difficult in distributed systems because the failure is partial i, e, some
components fail while others continue to function.
Concurrency: There is a possibility that several clients will attempt to access a shared resource
at the same time. Multiple users make requests on the same resources, i.e read, write, and
update. Each resource must be safe in a concurrent environment. Any object that represents a
shared resource a distributed system must ensure that it operates correctly in a concurrent
environment.
Transparency: Transparency ensures that the distributes system should be perceived as the
single entity by the users or the application programmers rather than the collection of
autonomous systems, which is cooperating. The user should be unaware of where the services
are located and the transferring from a local machine to a remote one should be transparent.
Q3-c) Why synchronization is required in DOS? Explain algorithm used to
achieve synchronization of clock in DOS.
Distributed System is a collection of computers connected via the high-speed communication
network. In the distributed system, the hardware and software components communicate and
coordinate their actions by message passing. Each node in distributed systems can share their
resources with other nodes. So, there is need of proper allocation of resources to preserve the
state of resources and help coordinate between the several processes. To resolve such conflicts,
synchronization is used. Synchronization in distributed systems is achieved via clocks.
10 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
The physical clocks are used to adjust the time of nodes. Each node in the system can share its
local time with other nodes in the system. The time is set based on UTC (Universal Time
Coordination). UTC is used as a reference time clock for the nodes in the system.
There are 2 types of clock synchronization algorithms: Centralized and Distributed.
1. Centralized is the one in which a time server is used as a reference. The single time
server propagates its time to the nodes and all the nodes adjust the time accordingly. It is
dependent on single time server so if that node fails, the whole system will lose
synchronization. Examples of centralized are- Berkeley Algorithm, Passive Time Server,
Active Time Server etc.
2. Distributed is the one in which there is no centralized time server present. Instead the
nodes adjust their time by using their local time and then, taking the average of the
differences of time with other nodes. Distributed algorithms overcome the issue of
centralized algorithms like the scalability and single point failure. Examples of
Distributed algorithms are – Global Averaging Algorithm, Localized Averaging
Algorithm, NTP (Network time protocol) etc.
Algorithms for synchronization for clock :-
Cristian’s Algorithm
Cristian’s Algorithm is a clock synchronization algorithm is used to synchronize time with a
time server by client processes. This algorithm works well with low-latency networks
where Round Trip Time is short as compared to accuracy while redundancy prone distributed
systems/applications do not go hand in hand with this algorithm. Here Round Trip Time refers
to the time duration between start of a Request and end of corresponding Response.
Below is an illustration imitating working of cristian’s algorithm:
11 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
Berkeley’s Algorithm
Berkeley’s Algorithm is a clock synchronization technique used in distributed systems. The
algorithm assumes that each machine node in the network either doesn’t have an accurate time
source or doesn’t possess an UTC server.
Algorithm: -
1) An individual node is chosen as the master node from a pool node in the network. This node
is the main node in the network which acts as a master and rest of the nodes act as slaves.
Master node is chosen using a election process/leader election algorithm.
2) Master node periodically pings slaves nodes and fetches clock time at them using Cristian’s
algorithm.
Diagram below illustrates how the master sends request to slave nodes.
12 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
OR Q3-a) Explain desirable features of a good message passing system.
~Simplicity:-
•A message passing system should be simple and easy to use.
•It must be straight forward to construct new applications and to communicate with existing
one by using the primitives provided by message passing system.
~Uniform Semantics :-
• In a distributed system, a message-passing system may be used for the following two types
of inter process communication:
• Local communication, in which the communicating processes are on the same node.
~Efficiency :-
•An IPC protocol of a message-passing system can be made efficient by reducing the number
of message exchanges, as far as practicable, during the communication process.
~Reliability :-
•A good IPC protocol can cope with failure problems and guarantees the delivery of a message.
•Handling of lost messages involves acknowledgement and retransmission on the basis of
timeouts.
•A reliable IPC protocol should also be capable of detecting and handling duplicate messages.
OR Q3-b) Explain Remote Procedure Call model.
THE RPC MODEL :-
The RPC model is similar to the well-known and well-understood procedure call model used
for the transfer of control and data within a program in the following manner:
1. For making a procedure call, the caller places arguments to the procedure in some well-
specified location.
2. Control is then transferred to the sequence of instructions that constitutes the body of the
procedure.
3. The procedure body is executed in a newly created execution environment that includes
copies of the arguments given in the calling instruction.
4. After the procedure's execution is over, control returns to the calling point, possibly returning
a result.
The RPC mechanism is an extension of the procedure call mechanism in the sense that it
enables a call to be made to a procedure that does not reside in the address space of the calling
process. The called procedure (commonly called remote procedure) may be on the same
computer as the calling process or on a different computer.
13 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
In case of RPC, since the caller and the callee processes have disjoint address spaces (possibly
on different computers), the remote procedure has no access to data and variables of the caller's
environment. Therefore the RPC facility uses a message-passing scheme for information
exchange between the caller and the callee processes
When a remote procedure call is made, the caller and the callee processes interact in the
following manner :-
1. The caller (commonly known as client process) sends a call (request) message to the callee
(commonly known as server process) and waits (blocks) for a reply message. The request
message contains the remote procedure's parameters, among other things.
2. The server process executes the procedure and then returns the result of procedure execution
ina reply message to the client process.
3. Once the reply message is received, the result of procedure execution is extracted, and the
caller's execution is resumed.
OR Q3-c) Explain Bully Algorithm.
Bully Algorithm
• Any process P can initiate an check.
• P sends election message to all process with higher IDS and awaits OK messages.
14 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
• If no OK messages, P becomes coordinator and sends coordinator messages to all
processes.
• If it receives an OK, it drops out and waits for an coordinator.
• If a process receive an election message.
• Immediately sends coordinator message if it is the process with highest ID.
• Otherwise returns an OK and start election.
• If a process receives a coordinator message, it treats sender as a co-coordinator.
Bully Algorithm : Assume p10 = 7 is co-coordinator.
p4 p7 has failed and hence start election for all process higher then p4.
15 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
∵∵ ps & p6 assume they bully p1 by sending OK.
Now i5 & p6 start election.
16 | 1 8 1 2 4 3 1 0 7 0 0 4 Distributed Operating System
Now p6 bully.
∵∵ no one can bully p6
∵∵ p6 becomes co-coordinator R informs everyone.