You are on page 1of 21

Master of Computer Application (MCA) Semester 5 MC0085 Advanced Operating Systems Assignment Set 1

1. Discuss the following with respect to Message Passing in Distributed Systems: a. Synchronization Ans: A major issue in communication is the synchronization imposed on the communicating processes by the communication primitives. There are two types of communicating primitives: Blocking Semantics and Non-Blocking Semantics. Blocking Semantics: A communication primitive is said to have blocking semantics if its invocation blocks the execution of its invoker (for example in the case of send, the sender blocks until it receives an acknowledgement from the receiver.) Non-blocking Semantics: A communication primitive is said to have non-blocking semantics if its invocation does not block the execution of its invoker. The synchronization imposed on the communicating processes basically depends on one of the two types of semantics used for the send and receive primitives. Blocking Primitives Blocking Send Primitive: In this case, after execution of the send statement, the sending process is blocked until it receives an acknowledgement from the receiver that the message has been received. Non-Blocking Send Primitive: In this case, after execution of the send statement, the sending process is allowed to proceed with its execution as soon as the message is copied to the buffer. Blocking Receive Primitive: In this case, after execution of the receive statement, the receiving process is blocked until it receives a message. Non-Blocking Receive Primitive: In this case, the receiving process proceeds with its execution after the execution of receive statement, which returns the control almost immediately just after telling the kernel where the message buffer is. Handling non-blocking receives: The following are the two ways of doing this: Polling: a test primitive is used by the receiver to check the buffer status

Interrupt: When a message is filled in the buffer, software interrupt is used to notify

the receiver. However, user level interrupts make programming difficult. Handling blocking receives: A timeout value may be used with a blocking receive primitive to prevent a receiving process from getting blocked indefinitely if the sender has failed. Synchronous Vs Asynchronous Communication When both send and receive primitives of a communication between two processes use blocking semantics, the communication is said to be synchronous. If one or both of the primitives is non-blocking, then the communication is said to be asynchronous. Synchronous communication is easy to implement. It contributes to the reliable delivery of messages. Asynchronous communication limits concurrency and is prone to communication deadlocks.

b. Buffering
Ans: The transmission of messages from one process to another can be done by copying

the body of the message from the senders address space to the receivers address space. In some cases, the receiving process may not be ready to receive the message but it wants the operating system to save that message for later reception. In such cases, the operating system would rely on the receivers buffer space in which the transmitted messages can be stored prior to receiving process executing specific code to receive the message. The synchronous and asynchronous modes of communication correspond to the two extremes of buffering: a null buffer, or no buffering, and a buffer with unbounded capacity. Two other commonly used buffering strategies are single-message and finitebound, or multiple message buffers. These four types of buffering strategies are given below: o No buffering: In this case, message remains in the senders address space until the receiver executes the corresponding receive. o Single message buffer: A buffer to hold a single message at the receiver side is used. It is used for implementing synchronous communication because in this case an application can have only one outstanding message at any given time. o Unbounded - Capacity buffer: Convenient to support asynchronous communication. However, it is impossible to support unbounded buffer. o Finite-Bound Buffer: Used for supporting asynchronous communication.

Buffer overflow can be handled in one of the following ways: o Unsuccessful communication: send returns an error message to the sending process, indicating that the message could not be delivered to the receiver because the buffer is full.

o Flow-controlled communication: The sender is blocked until the receiver accepts some messages. This violates the semantics of asynchronous send. This will also result in communication deadlock. A message data should be meaningful to the receiving process. This implies ideally that the structure of the program should be preserved while they are being transmitted from the address space of the sending process to the address space of the receiving process. It is not possible in heterogeneous systems in which the sending and receiving processes are on computers of different architectures. Even in homogeneous systems, it is very difficult to achieve this goal mainly because of two reasons: 1. An absolute pointer value has no meaning (more on this when we talk about RPC). For example, a pointer to a tree or linked list. So, proper encoding mechanisms should be adopted to pass such objects. 2. Different program objects, such as integers, long integers, short integers, and character strings occupy different storage space. So, from the encoding of these objects, the receiver should be able to identify the type and size of the objects. One of the following two representations may be used for the encoding and decoding of a message data: 1. Tagged representation: The type of each program object as well as its value is encoded in the message. In this method, it is a simple matter for the receiving process to check the type of each program object in the message because of the self-describing nature of the coded data format. 2. Untagged representation: The message contains only program objects, no information is included in the message about the type of each program object. In this method, the receiving object should have a prior knowledge of how to decode the received data because the coded data format is not self-describing. The untagged representations used in SUNs XDR format and tagged representation is used in Mach distributed operating system.

c. Process Addressing Ans: A message passing system generally supports two types of addressing: o Explicit Addressing: The process with which communication is desired is explicitly specified as a parameter in the communication primitive. e.g. send (pid, msg), receive (pid, msg).

Implicit Addressing: A process does not explicitly name a process for communication. For example, a process can specify a service instead of a process. e.g. send any (service id, msg), receive any (pid, msg) Methods for process addressing: o machine id@local id: UNIX uses this form of addressing (IP address, port number).

Advantages: No global coordination needed for process addressing. Disadvantages: Does not allow process migration. o machine id1@local id@machine id2: machine id1 identifies the node on which the process is created. local id is generated by the node on which the process is created. machine id2 identifies the last known location of the process. When a process migrates to another node, the link information (the machine id to which the process migrates) is left with the current machine. This information is used for forwarding messages to migrated processes. Disadvantages: Overhead involved in locating a process may be large. If the node on which the process was executing is down, it may not be possible to locate the process.

d. Failure Handling Ans: While a distributed system may offer potential for parallelism, it is also prone to partial failures such as a node crash or a communication link failure. During Interprocess communication, such failures may lead to the following problems: Loss of request Message: This can be due to link failure or receiver node is down. Loss of response message: This may be due to link failure or the sender is down when the response reaches it. Unsuccessful execution of request: This may be due to receiver node crash while processing the request.

A Solution to overcome the above said problem may be done using the following methods: 1. A four message reliable IPC: In this method there are four messages involved: Request and Acknowledgement from the client machine, Reply and Acknowledgement from the Server machine. In this case, the kernels of both the client and server will continue to retransmit after timeout until an acknowledgement is received from both, i.e the client machine sends a request message to the server machine and waits for an acknowledgement from the server. If the acknowledgement is not received within the specified timeout period, the client retransmits its request to the server and waits for an acknowledgement. This process continues till an acknowledgement is received. The same process occurs even at the server side. The server sends a reply message to the client and waits for the acknowledgement until the specified timeout period. On non-receipt of the acknowledgement within the timeout period, it resends the reply back to the client machine and the process continues till the client responds with an acknowledgement. 2. Three message reliable IPC: As mentioned in point number 1 above, the scenario here slightly varies, wherein the client machine does not wait for an acknowledgement to be received from the server machine. The client machine just sends the request to the specified server. But here the server machine expects an acknowledgement from the client machine when it responds to the clients request message. The server now waits for an acknowledgement from the client and on non-receipt of the acknowledgement within the specified time period, it retransmits the reply message to the client and this cycle continues until the client responds with an acknowledgement. In this method, the server may use the concept of piggybacking, wherein it may attach the acknowledgement to the client with a message in the form of a reply to the client. 3. Two message reliable IPC: In this method there is no requirement either from the client or the server for receiving acknowledgements from each other. They just exchange the messages in the form of requests and replies or responses to each other assuming that their messages have been sent (ideal scenario), but which may be impractical in real time situations. Idempotency and handling of duplicate request messages Idempotency basically means repeatability. i.e. an Idempotent operation produces the same results without any side effects no matter how many times it is performed with the same arguments. For example, assume an sqrt procedure for calculating the square root of a given number; sqrt (64) always returns 8. On the other hand, operations that do not necessarily produce the same results when executed repeatedly with the same arguments are said to be non-idempotent. For example a debit operation on a bank account.

An idempotent operation produces the same result without any side effect no matter how many times it is executed. Not all operations are idempotent So, if requests can be retransmitted, then care should be taken to implement its reply as an idempotent operation.

e. Group Communication Ans: The most elementary form of message-based interaction is one-to-one communication in which a single-sender process sends a message to a single receiver process. However, for performance and ease of programming several highly parallel distributed applications require that a message passing system should also provide group communication facility. Depending on single or multiple senders and receivers, the following three types of group communication are possible: 1. One-to-many (Single sender and multiple receivers) 2. Many-to-one (multiple senders and single receiver) 3. Many-to-many (multiple senders and multiple receivers) The following are the One-to-Many Multicast issues in a group communication to be addressed: i) Group Management: In case of one-to-many communication, receiver processes of a message form a group. Such groups are of two types closed and open. A closed group is one in which only the members of the group can send a message to the group. An outside process cannot send a message to the group as a whole, although it may send a message to an individual member of the group. On the other hand an open group is one in which any process in the system can send a message to the group as a whole. Whether to use a closed group or an open group is application dependent. A message passing system with group communication facility provides the flexibility to create an delete groups dynamically and to allow a process to join or leave a group at any time. ii) Group Addressing: A two-level naming scheme is normally used for group addressing. The higher level group is an ASCII string that is independent of the location information of the processes in the group. The low-level group name depends to a large extent on the underlying hardware. For example, on some networks it is possible to create a special network address to which multiple machines can listen.

Create a special network address, called multicast address. A packet sent to multicast address is delivered to all who have subscribed to that group.

For example, on the Internet, class D IP addresses are used for multicast. The format of class D IP addresses for IP multicasting: -------------------------------------|1|1|1|0| Group identification| -------------------------------------The first four bits contain 1110 and identify the address as multicast. The remaining 28 bits specify a specific multicast group. Broadcast address: A certain address is declared as a broadcast address and packets sent to that address are delivered to all in the network. If there is no facility to create multicast or broadcast addresses, then underlying unicast is used. A disadvantage is for each member a separate copy of each packet needs to be sent.

iii) Message Delivery Approach: The following are the two possible approaches

for message delivery.


: A centralized group server maintains information

about the groups and their members.


: No central server keeps the information. Buffered or Unbuffered: A multicast packet can be buffered until the receiver is ready to receive. If unbuffered, packets could be lost. Multicast send is inherently asynchronous:

processes that belong to the multicast group are ready to receive.

Flexible Reliability in Multicast Communication: Different levels of reliability


O-reliable: No response is expected from any receivers.

1-reliable: Sender expects response from one receiver (may be the multicast server can take the responsibility).

m-out-of-n-reliable: The sender expects response from m out of n receivers.

All-reliable: The sender expects response from all receivers.


Atomic Multicast: A multicast message is received by all the members of the group or

none.
Different Implementation methods: The Kernel of the sender is responsible for retransmitting until everyone receives.

This method works only if the senders machine and none of the receiver processes fail. Each receiver of the multicast message performs an atomic multicast of the same message to the same group. This method ensures all surviving processes will receive the message even if some receivers fail after receiving the message or the sender machine fails after sending the message.
iv) Many-to-One Communication: In this type of communication, multiple senders

send messages to a single receiver. For example, A buffer process may receive messages from several consumers and producers. Multicast recipients may be sending acknowledgements to the sender . A database server may be receiving requests from several clients
v) Many-to-Many Communication: In this type of communication, multiple senders

send messages to multiple receivers. An important issue here is that of ordered delivery of messages. Ordered delivery ensures that all messages are delivered to all receivers in an order acceptable to the application. The following are the various message ordering semantics followed in case of a Many-to-Many communication:
i) Absolute Ordering: In this type, all messages are delivered to all processes in the

exact order in which they were sent. Not possible to implement in the absence of global clock. Moreover, absolute ordering is not required by many applications.
ii) Consistent Ordering: In this type, all messages are received by all processes in the

same order.

iii) Causal Ordering: For some applications, consistent-ordering semantics is not

necessary and even weaker semantics is acceptable. An application can have better performance if the message-passing system used supports a weaker ordering semantics that is acceptable to the application. One such weak ordering semantics that is acceptable to many applications is the causal ordering semantics. This semantics ensures that if the event of sending one message is causally related to the event of sending another message, the two messages are delivered to all receivers in the correct order. Two message sending events are said to be causally related if they are correlated by the happened-before relation. i.e. two message sending events are causally related if there is any possibility of the second one being influenced in any way by the first one. The basic idea behind causal ordering semantics is that when it matters, messages are always delivered in proper order, but when it does not matter, they may be delivered in any arbitrary order.

2. Discuss the following with respect to Distributed Shared Memory: a. Memory Coherence (Consistency) Models Ans: Memory Consistency Model is: A set of rules that the applications must obey if they want the DSM system to provide the degree of consistency guaranteed by the consistency model. Weaker the consistency model, better the concurrency. Researchers try to invent new consistency models which are weaker than the existing ones in such a way that a set of applications will function correctly under the new consistency model.
Note that an application written for a DSM that implements a stronger

consistency model may not work correctly under a DSM that implements a weaker consistency model. b. Memory Consistency models Ans: i) Strict consistency: Each read operation returns the most recently written value. This is possible to implement only in systems with the notion of global time. So, this model is impossible to implement. Hence, DSM systems based on underlying distributed systems have to use weaker consistency models. ii) Sequential consistency: Proposed by Lamport (1979). All processes in the system observe the same order of all memory access operations on the shared memory. i.e., if three operations read(r1), write(w1) and read(r2) are performed on a

memory address in that order, then any of the six orderings (r1,w1, r2), (r2,w1, r1), (w1, r2, r1).... is acceptable provided all processes see the same ordering. It can be implemented by serializing all requests on a central server node. This model is weaker than the strict consistency model. This model provides onecopy/single-copy semantics because all processes sharing a memory location always see exactly the same contents stored in it. Sequential consistency is the most intuitively expected semantics for memory coherence. So, sequential consistency is acceptable for most applications. iii) Causal consistency model: Proposed by Hutto and Ahamad (1990). In this model, all write operations that are potentially causally related are seen by all processes in the same (correct) order. For example, if a process did a read operation and then performed a write operation, then the value written may have depended in some way on the value read. A write operation performed by one process P1 is not causally related to the write operation performed by another process P2 if P1 has read neither the value written by P2 or any memory variable that was directly or indirectly derived from the value written by P2 and vice versa. For implementing DSMs that support causal consistency one has to keep track of which memory operation is dependent on which other operation. This model is weaker than Sequential consistency model Pipelined Random - Access Memory (PRAM) consistency model. This model was proposed by Lipton and Sandberg (1988). In this model, all write operations performed by a single process are seen by all other processes in the order in which they were performed. This model can be implemented easily by sequencing the write operations performed by each node independently. This model is weaker than all the above consistency models. Processor Consistency Model: Proposed by Goodman (1989). In addition to PRAM consistency, for any memory location, all processes agree on the same order of all write operations to that location. Weak Consistency Model: Proposed by Dubois et al. (1988). This model distinguishes between ordinary accesses and synchronization accesses. It requires that memory become consistent only on synchronization accesses. A DSM that supports weak consistency model uses a special variable, called synchronization variable. The operations on it are used to synchronize memory. For supporting weak consistency, the following should be satisfied: All accesses to synchronization variables must obey sequential consistency semantics.

iii)

v)

vi)

All previous write operations must be completed everywhere before an

access to synchronization variable is allowed. access to a non synchronization variable is allowed. vii) Release Consistency Model: In the weak consistency model, the entire shared memory is synchronized when a synchronization variable is accessed by a process i.e. All changes made to the memory are propagated to other nodes. All changes made to the memory by other processes are propagated from other nodes to the processs node. This is not really necessary because the first operation needs to be performed only when a process exits from critical section and the second operation needs to be performed only when the process enters critical section. So, instead of one synchronization variable, two synchronization variables, called acquire and release have been proposed. Acquire is used by a process to tell the system that it is about to enter a critical section. Release is used to tell the system that it had exited critical section. If processes use appropriate synchronization accesses properly, a release consistency DSM system will produce the same results for an application as that if the application was executed on a sequentially consistent DSM system. viii) Lazy Release consistency model: It is a variation of release consistency model. In this approach, when a process does a release access, the contents of all the modifications are not immediately sent to other nodes but they are sent only on demand. i.e. When a process does an acquire access, all modifications of other nodes are acquired by the processs node. It minimizes network traffic.

b. Implementing Sequential Consistency


Ans: Sequential consistency supports the intuitively expected semantics. So, this

is the most preferred choice for designers of DSM system. The replication and migration strategies for DSM design include: i) Non-replicated, non-migrating blocks (NRNMBs) ii) Non-replicated, migrating blocks (NRMBs) iii) Replicated, migrating blocks (RMBs) iv) Replicated, non-migrating blocks (RNMBs)

i) Implementing under NRNMBs strategy: Under this strategy, only one copy of each block of the shared memory is in the system and its location is fixed. All requests for a block are sent to the owner node of the block. Upon receiving a request from a client node, the memory management unit (MMU) and the operating system of the owner node perform the access request and return the result. Sequential consistency can be trivially enforced, because the owner node needs to only process all requests on a block in the order it receives.

Parallelism is not possible in this strategy. need to be maintained at each node. ii) Implementing under NRMBs strategy Under this strategy, only the processes executing on one node can read or write a given data item at any time, so sequential consistency is ensured. The advantages of this strategy include: No communication cost for local data access. Allows applications to take advantage of data access locality The disadvantages of this strategy include: Prone to thrashing Parallelism cannot be achieved in this method also Locating a block in the NRMB strategy: 1. Broadcasting: Under this approach: Each node maintains a owned blocks table When a block fault occurs, the fault handler broadcasts a request on the network. The node that currently owns the block responds by transferring the block. This approach does not scale well. 2. Centralized Server Algorithm: A central server maintains a block table that contains the location information for all blocks in the shared memory space When a block fault occurs, the fault handler sends a request to the central server. The central server forwards the request to the node holding block and updates its block table. Upon receiving the request, the owner transfers the block to the requesting node. Drawbacks:

3. Fixed Distributed Server Algorithm: Under this scheme: Several nodes have block managers, each block manager manages a predetermined set of blocks Each node maintains a mapping from data blocks to block managers When a block fault occurs, the fault handler sends a request to the corresponding block manager The block manager forwards the request to the corresponding node and updates its table to reflect the new owner (the node requesting the block) Upon receiving the request, the owner transfers the block to the requesting node. 4. Dynamic Distributed Server Algorithm: Under this approach there is no block manager. Each node maintains information about the probable owner of each block. When a block fault occurs, the fault handler sends a request to the probable owner of the block. Upon receiving the request, if the receiving node is the owner of the block, it updates its block table and transfers the block to the requesting node; otherwise, it forwards the request to the probable owner of the block as indicated by its block table. Implementing under RMBs strategy A major disadvantage of non replication strategies is lack of parallelism because only the processes on one node can access data contained in any given block at any given time. To increase parallelism, virtually all DSM systems replicate blocks. With replicated blocks, read operations can be carried out in parallel at multiple nodes by accessing the local copy of the data. Therefore the average cost of read operations is reduced because no communication overhead is involved if a replica of the data exists at the local node. However, replication tends to increase the cost of write operations because for a write to a block all its replicas must be invalidated or updated to maintain consistency.

d. Centralized Server Algorithm Ans: A central server maintains a block table containing owner-node and copyset information for each block. When a read/write fault for a block occurs at node N, the fault handler at node N sends a read/write request to the central server. Upon receiving the request, the central-server does the following: If it is a read request: adds N to the copy-set field and sends the owner node information to node N

upon receiving this information, N sends a request for the block to the owner node. upon receiving this request, the owner returns a copy of the block to N. If it is a write request: It sends the copy-set and owner information of the block to node N and initializes copy-set to {N} o Node N sends a request for the block to the owner node and an invalidation message to all blocks in the copy-set. o Upon receiving this request, the owner sends the block to node N

3. Explain the following with respect to Resource Management in Distributed Systems: a. Task assignment Approach Ans: In this approach, a process is considered to be composed of multiple tasks and the goal is to find an optimal assignment policy for the tasks of an individual process. The following are typical assumptions for the task assignment approach: A process is already split into pieces, called tasks The amount of computation required for each task and the speed of the processors are known Cost of processing each task at every node is known The interprocess communication between any two processes is known Resource requirements of each task Reassignment of tasks is generally not possible

Some of the goals of a good task assignment algorithm are: Minimize IPC cost (this problem can be modeled using network flow model) Efficient resource utilization Quick turnaround time A high degree of parallelism

b. Load Balancing Approach Ans: The scheduling algorithms that use this approach are known as Load Balancing or Load-Leveling Algorithms. These algorithms are based on the intuition that for better resource utilization, it is desirable for the load in a distributed system to be balanced evenly. Thus a load balancing algorithm tries to balance the total system load by

transparently transferring the workload from heavily loaded nodes to lightly loaded nodes in an attempt to ensure good overall performance relative to some specific metric of system performance. We can have the following categories of load balancing algorithms: 1. Static: Ignore the current state of the system. e.g. If a node is heavily loaded, it picks up a task randomly and transfers it to a random node. These algorithms are simpler to implement but performance may not be good. 2. Dynamic: Use the current state information for load balancing. There is an overhead involved in collecting state information periodically; they perform better than static algorithms. 3. Deterministic: Algorithms in this class use the processor and process characteristics to allocate processes to nodes. 4. Probabilistic: Algorithms in this class use information regarding static attributes of the system such as number of nodes, processing capability, etc. 5. Centralized: System state information is collected by a single node. This node makes all scheduling decisions. 6. Distributed: Most desired approach. Each node is equally responsible for making scheduling decisions based on the local state and the state information received from other sites. 7. Cooperative: A distributed dynamic scheduling algorithm. In these algorithms, the distributed entities cooperate with each other to make scheduling decisions. Therefore they are more complex and involve larger overhead than non-cooperative ones. But the stability of a cooperative algorithm is better than that of a non-cooperative one. 8. Non-cooperative: A distributed dynamic scheduling algorithm. In these algorithms, individual entities act as autonomous entities and make scheduling decisions independently of the action of other entities.

c. Load Sharing Approach Ans: Several researchers believe that load balancing, with its implication of attempting to equalize workload on all the nodes of the system, is not an appropriate objective. This is because the overhead involved in gathering the state information to achieve this objective is normally very large, especially in distributed systems having a large number of nodes. In fact, for the proper utilization of resources of a distributed system, it is not required to balance the load on all the nodes. It is necessary and sufficient to prevent

the nodes from being idle while some other nodes have more than two processes. This rectification is called the Dynamic Load Sharing instead of Dynamic Load Balancing. Issues in Load-Sharing Algorithms: The design of a load sharing algorithm requires that proper decisions be made regarding load estimation policy, process transfer policy, state information exchange policy, priority assignment policy, and migration limiting policy. It is simpler to decide about most of these policies in case of load sharing, because load sharing algorithms do not attempt to balance the average workload of all the nodes of the system. Rather, they only attempt to ensure that no node is idle when a node is heavily loaded. The priority assignment policies and the migration limiting policies for load-sharing algorithms are the same as that of load-balancing algorithms. 1. Load Estimation Policies: In this an attempt is made to ensure that no node is idle while processes wait for service at some other node. In general, the following two approaches are used for estimation: Use number of processes at a node as a measure of load Use the CPU utilization as a measure of load Process Transfer Policies: Load sharing algorithms are interested in busy or idle states only and most of them employ the all-or-nothing strategy given below: All or Nothing Strategy: It uses a single threshold policy. A node becomes a candidate to accept tasks from remote nodes only when it becomes idle. A node becomes a candidate for transferring a task as soon as it has more than one task. Under this approach, an idle process is not able to immediately acquire a task, thus wasting processing power. To avoid this, the threshold value can be set to 2 instead of 1. Location Policies: Location Policy decides the sender node or the receiver node of a process that is to be moved within the system for load sharing. Depending on the type of node that takes the initiative to globally search for a suitable node for the process, the location policies are of the following types:

1. Sender-Initiated Policy: Under this policy, heavily loaded nodes search for lightly loaded nodes to which task may be transferred. The search can be done by sending a broadcast message or probing randomly picked nodes An advantage of this approach is that sender can transfer the freshly arrived tasks, so no preemptive task transfers occur. A disadvantage of this approach is it can cause system instability under high system load. 2. Receiver-Initiated Location Policy: Under this policy, lightly loaded nodes search for heavily loaded nodes from which tasks may be transferred

The search for a sender can be done by sending a broadcast message or by probing randomly picked nodes. An disadvantage of this approach is it may result in preemptive task transfers because sender may not have any freshly arrived tasks. Advantage is, this does not cause system instability, because under high system loads a receiver will quickly find a sender; and under low system loads, it is OK for processes to process some additional control messages.

3. Symmetrically Initiated Location Policy: Under this approach, both senders and receivers search for receivers and senders respectively. 4. State Information Exchange Policies: Since it is not necessary to equalize load at all nodes under load sharing, state information is exchanged only when the state changes. 5. Broadcast When State Changes: A node broadcasts a state information request message when it becomes under-loaded or overloaded. In the sender-initiated approach a node broadcasts this message only when it is overloaded. In the receiver-initiated approach, a node broadcasts this message only when it is under-loaded. 6. Poll When State Changes: When a nodes state changes, It randomly polls other nodes one by one and exchanges state information with the polled nodes. Polling stops when a suitable node is found or a threshold number of nodes have been polled. Under sender initiated policy, sender polls to find suitable receiver. Under receiver initiated policy, receiver polls to find suitable sender. The above Average Algorithm by Krueger and Finkel (A dynamic load balancing algorithm) tries to maintain load at each node within an acceptable range of the system average. 7. Transfer Policy: A threshold policy that uses two adaptive thresholds, the upper threshold, and the lower threshold A node with load lower than lower threshold is considered a receiver A node with load higher than the higher threshold is considered a sender. A nodes estimated average load is supposed to lie in the middle of the lower and upper thresholds.

4. Explain the following with respect to Distributed File Systems:

a. The Key Challenges of Distributed Systems Ans: A good distributed file system should have the features described below: i) Transparency Location: a client cannot tell where a file is located Migration: a file can transparently move to another server Replication: multiple copies of a file may exist Concurrency: multiple clients access the same file

ii) Flexibility In a flexible DFS it must be possible to add or replace file servers. Also, a DFS should support multiple underlying file system types (e.g., various Unix file systems, various Windows file systems, etc.) iii) Reliability In a good distributed file system, the probability of loss of stored data should be minimized as far as possible. i.e. users should not feel compelled to make backup copies of their files because of the unreliability of the system. Rather, the file system should automatically generate backup copies of critical files that can be used in the event of loss of the original ones. Stable storage is a popular technique used by several file systems for higher reliability. iv) Consistency: Employing replication and allowing concurrent access to files may introduce consistency problems. v) Security: Clients must authenticate themselves and servers must determine whether clients are authorised to perform requested operation. Furthermore communication between clients and the file server must be secured. vi) Fault tolerance: Clients should be able to continue working if a file server crashes. Likewise, data must not be lost and a restarted file server must be able to recover to a valid state. vii) Performance: In order for a DFS to offer good performance it may be necessary to distribute requests across multiple servers. Multiple servers may also be required if the amount of data stored by a file system is very large. viii) Scalability: A scalable DFS will avoid centralised components such as a centralised naming service, a centralised locking facility, and a centralised file store. A scalable DFS must be able to handle an increasing number of files and users. It must also be able to

handle growth over a geographic area (e.g., clients that are widely spread over the world), as well as clients from different administrative domains. b. Clients Perspective: File Services Ans: The File Service Interface represents files as an uninterpreted sequence of bytes that are associated with a set of attributes (owner, size, creation date, permissions, etc.) including information regarding protection (i.e., access control lists or capabilities of clients). Moreover, there is a choice between the upload/download model and the remote access model. In the first model, files are downloaded from the server to the client. Modifications are performed directly at the client after which the file is uploaded back to the server. In the second model all operations are performed at the server itself, with clients simply sending commands to the server. There are benefits and drawbacks to both models. The first model, for example, can avoid generating traffic every time it performs operations on a file. Also, a client can potentially use a file even if it cannot access the file server. A drawback of performing operations locally and then sending an updated file back to the server is that concurrent modification of a file by different clients can cause problems. The second approach makes it possible for the file server to order all operations and therefore allow concurrent modifications to the files. A drawback is that the client can only use files if it has contact with the file server. If the file server goes down, or the network connection is broken, then the client loses access to the files. c. File Access Semantics Ans: Ideally, the client would perceive remote files just like local ones. Unfortunately, the distributed nature of a DFS makes this goal hard to achieve. In the following discussion, we present the various file access semantics available, and discuss how appropriate they are to a DFS. The first type of access semantics that we consider are called Unix semantics and they imply the following: A read after a write returns the value just written. When two writes follow in quick succession, the second persists.

In the case of a DFS, it is possible to achieve such semantics if there is only a single file server and no client-side caching is used. In practice, such a system is unrealistic because caches are needed for performance and write-through caches (which would make Unix semantics possible to combine with caching) are expensive. Furthermore deploying only a single file server is bad for scalability. Because of this it is impossible to achieve Unix semantics with distributed file systems. Alternative semantic models that are better suited for a distributed implementation include:

1. Session semantics, 2. Immutable files, and 3. Atomic transactions.

1. Session Semantics: In the case of session semantics, changes to an open file are only locally visible. Only after a file is closed, are changes propagated to the server (and other clients). This raises the issue of what happens if two clients modify the same file simultaneously. It is generally up to the server to resolve conflicts and merge the changes. Another problem with session semantics is that parent and child processes cannot share file pointers if they are running on different machines. 2. Immutable Files: Immutable files cannot be altered after they have been closed. In order to change a file, instead of overwriting the contents of the existing file a new file must be created. This file may then replace the old one as a whole. This approach to modifying files does require that directories (unlike files) be updatable. Problems with this approach include a race condition when two clients try to replace the same file as well as the question of what to do with processes that are reading a file at the same time as it is being replaced by another process. 3. Atomic Transactions: In the transaction model, a sequence of file manipulations can be executed indivisibly, which implies that two transactions can never interfere. This is the standard model for databases, but it is expensive to implement. d. Servers Perspective Implementation Ans: Observations about the expected use of a file system can be used to guide the design of a DFS. For example, a study by Satyanarayanan found the following usage patterns for Unix systems at a university: Most files are small less than 10k Reading is much more common than writing Usually access is sequential; random access is rare Most files have a short lifetime File sharing is unusual Most processes use only a few files Distinct files classes with different properties exist

These usage patterns (small files, sequential access, high read-write ratio) would suggest that an update/download model for a DFS would be appropriate. Note, however, that different usage patterns may be observed at different kinds of institutions. In situations where the files are large, and are updated more often it may make more sense to use a DFS that implements a remote access model. Besides the usage characteristics, implementation tradeoffs may depend on the requirements of a DFS. These include supporting a large file system, supporting many users, the need for high performance, and the need for fault tolerance. Thus, for example, a fault tolerant DFS may sacrifice some performance for better reliability guarantees, while a high performance DFS may sacrifice security and wide-area scalability in order to achieve extra performance. e. Stateful Versus Stateless Servers Ans: The file servers that implement a distributed file service can be stateless or stateful. Stateless file servers do not store any session state. This means that every client request is treated independently, and not as part of a new or existing session. Stateful servers, on the other hand, do store session state. They may, therefore, keep track of which clients have opened which files, current read and write pointers for files, which files have been locked by which clients, etc. The main advantage of stateless servers is that they can easily recover from failure. Because there is no state that must be restored, a failed server can simply restart after a crash and immediately provide services to clients as though nothing happened. Furthermore, if clients crash the server is not stuck with abandoned opened or locked files. Another benefit is that the server implementation remains simple because it does not have to implement the state accounting associated with opening, closing, and locking of files. The main advantage of stateful servers, on the other hand, is that they can provide better performance for clients. Because clients do not have to provide full file information every time they perform an operation, the size of messages to and from the server can be significantly decreased. Likewise the server can make use of knowledge of access patterns to perform read-ahead and do other optimisations. Stateful servers can also offer clients extra services such as file locking, and remember read and write positions.

You might also like