Mc0085 Solve

Embed Size (px)

Citation preview

  • 7/30/2019 Mc0085 Solve

    1/8

    1. What is a message passing system? Discuss the desirable feature of a message passingsystem.

    Ans.

    Message passing is the paradigm of communication where messages are sent from a sender toone or more recipients. Forms of messages include (remote) method invocation, signals, and data

    packets. When designing a message passing system several choices are made:

    Whether messages are transferred reliably

    Whether messages are guaranteed to be delivered in order

    Whether messages are passed one-to-one, one-to-many (multicasting or broadcasting), or

    many-to-one (clientserver).

    Whether communication is synchronous or asynchronous.

    Prominent theoretical foundations of concurrent computation, such as the Actor model and the

    process calculi are based on message passing. Implementations of concurrent systems that use

    message passing can either have message passing as an integral part of the language, or as a

    series of library calls from the language. Examples of the former include many distributed object

    systems. Examples of the latter include Microkernel operating systems pass messages between

    one kernel and one or more server blocks, and the Message Passing Interface used in high-

    performance computing.

    Message passing systems and models

    Distributed object and remote method invocation systems like ONC RPC, Corba, Java RMI,

    DCOM, SOAP, .NET Remoting, CTOS, QNX Neutrino RTOS, OpenBinder, D-Bus and similar

    are message passing systems.

    Message passing systems have been called "shared nothing" systems because the messagepassing abstraction hides underlying state changes that may be used in the implementation of

    sending messages.

    Message passing model based programming languages typically define messaging as the (usually

    asynchronous) sending (usually by copy) of a data item to a communication endpoint (Actor,

    process, thread, socket, etc.). Such messaging is used in Web Services by SOAP. This concept is

    the higher-level version of a datagram except that messages can be larger than a packet and can

    optionally be made reliable, durable, secure, and/or transacted.

    Messages are also commonly used in the same sense as a means of interprocess communication;

    the other common technique being streams or pipes, in which data are sent as a sequence of

    elementary data items instead (the higher-level version of a virtual circuit).Examples of message passing style

    #Actor model implementation

    #Amorphous computing

    #Flow-based programming

    #SOAP (protocol)

    Synchronous versus asynchronous message passing

  • 7/30/2019 Mc0085 Solve

    2/8

    Synchronous message passing systems require the sender and receiver to wait for each other to

    transfer the message. That is, the sender will not continue until the receiver has received the

    message.

    Synchronous communication has two advantages. The first advantage is that reasoning about the

    program can be simplified in that there is a synchronisation point between sender and receiver on

    message transfer. The second advantage is that no buffering is required. The message can always

    be stored on the receiving side, because the sender will not continue until the receiver is ready.

    Asynchronous message passing systems deliver a message from sender to receiver, without

    waiting for the receiver to be ready. The advantage of asynchronous communication is that the

    sender and receiver can overlap their computation because they do not wait for each other

    Synchronous communication can be built on top of asynchronous communication by ensuring

    that the sender always wait for an acknowledgement message from the receiver before

    continuing.

    The buffer required in asynchronous communication can cause problems when it is full. Adecision has to be made whether to block the sender or whether to discard future messages. If the

    sender is blocked, it may lead to an unexpected deadlock. If messages are dropped, then

    communication is no longer reliable.

    2. Discuss the implementation of RPC Mechanism in detail.Ans:

    In computer science, a remote procedure call (RPC) is an inter-process communication that

    allows a computer program to cause a subroutine or procedure to execute in another address

    space (commonly on another computer on a shared network) without the programmer explicitly

    coding the details for this remote interaction. That is, the programmer writes essentially the samecode whether the subroutine is local to the executing program, or remote. When the software in

    question uses object-oriented principles, RPC is called remote invocation or remote method

    invocation.

    Note that there are many different (often incompatible) technologies commonly used to

    accomplish this.

    Message passing

    An RPC is initiated by the client, which sends a request message to a known remote server to

    execute a specified procedure with supplied parameters. The remote server sends a response to

    the client, and the application continues its process. There are many variations and subtleties in

    various implementations, resulting in a variety of different (incompatible) RPC protocols. While

    the server is processing the call, the client is blocked (it waits until the server has finished

    processing before resuming execution).

    An important difference between remote procedure calls and local calls is that remote calls can

    fail because of unpredictable network problems. Also, callers generally must deal with such

    failures without knowing whether the remote procedure was actually invoked. Idempotent

  • 7/30/2019 Mc0085 Solve

    3/8

    procedures (those that have no additional effects if called more than once) are easily handled, but

    enough difficulties remain that code to call remote procedures is often confined to carefully

    written low-level subsystems.

    Sequence of events during a RPC

    The client calls the Client stub. The call is a local procedure call, with parameters pushed on to

    the stack in the normal way.

    The client stub packs the parameters into a message and makes a system call to send the

    message. Packing the parameters is called marshalling.

    The kernel sends the message from the client machine to the server machine.

    The kernel passes the incoming packets to the server stub.

    Finally, the server stub calls the server procedure. The reply traces the same steps in the

    reverse direction.

    3. Discuss the following with respect to Distributed Shared Memory:a. Memory Coherence (Consistency) Models (2)b.

    Memory Consistency model(2)

    c. Implementing Sequential Consistency (3)d. Centralized Server Algorithm (3)

    Ans:

    (d) Centralized-Server Algorithm

    A central server maintains a block table containing owner-node and copy-set 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}

    Node N sends a request for the block to the owner node and an invalidation

    message to all blocks in the copy-set.

    Upon receiving this request, the owner sends the block to node N

    e. Memory Consistency model(2)Choosing an appropriate memory consistency model

    (MCM) is a tradeoff between minimizing memory access order constraints and the

    complexity of the programming model as well as of the complexity of the

    memory model itself. The weakest possible memory is

    one returning for a read access some previously written value or a value that will be

    written in the future.

  • 7/30/2019 Mc0085 Solve

    4/8

    Thus, the memory system could choose to return any

    of those values. While minimizing ordering constraints

    perfectly, it is not useful as a programming model. Implementing weaker models is

    also often more complex

    as it is necessary to keep track of outstanding accesses

    and restrict the order of execution of two accesses when

    necessary. It is therefore not surprising that many different MCMs have been

    proposed and new models are to

    be expected in the future. Unfortunately, there is no single hierarchy that could be

    used to classify the strictness

    of a consistency model. Below, we define the design

    space for consistency models. This allows us to classify

    the various models more easily.

    Memory consistency models impose ordering restrictions on accesses depending on a

    number of attributes.In general, the more attributes a model distinguishes,

    the weaker the model is. Some attributes a model could

    distinguish are listed below:

    location of access

    direction of access (read, write, or both)

    value transmitted in access

    causality of access

    4. Explain the following with respect to Resource Managemant of Distributed System:a. Task assignment Approachb. Load- Balancing Approachc. Load- Sharing approach

    Ans:

    A) Task assignment Approach

    Each process is viewed as a collection of tasks. These tasks are scheduled to suitable processor to

    improve performance. This is not a widely used approach because:

    It requires characteristics of all the processes to be known in advance.

    This approach does not take into consideration the dynamically changing state of thesystem.

    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:

  • 7/30/2019 Mc0085 Solve

    5/8

    Minimize IPC cost (this problem can be modeled using network flow model)

    Efficient resource utilization

    Quick turnaround time

    A high degree of parallelism

    B) Approach Load Balancing

    In this, the processes are distributed among nodes to equalize the load among all nodes. 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 isdesirable for the load in a distributed system to be balanced evenly. This a load balancingalgorithm 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:

    Static: Ignore the current state of the system. E.g. if a node is heavily loaded, it picks up atask randomly and transfers it to a random node. These algorithms are simpler to implement but

    performance may not be good.

    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.

    Deterministic: Algorithms in this class use the processor and process characteristics toallocate processes to nodes.

    Probabilistic: Algorithms in this class use information regarding static attributes of thesystem such as number of nodes, processing capability, etc.

    Centralized: System state information is collected by a single node. This node makes allscheduling decisions.

    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.

    Cooperative: A distributed dynamic scheduling algorithm. In these algorithms, the

    distributed entities cooperate with each other to make scheduling decisions. Therefore they aremore complex and involve larger overhead than non-cooperative ones. But the stability of a

    cooperative algorithm is better than of a non-cooperative one.

  • 7/30/2019 Mc0085 Solve

    6/8

    Non-Cooperative: A distributed dynamic scheduling algorithm. In these algorithms,

    individual entities act as autonomous entities and make scheduling decisions independently ofthe action of other entities.

    C) Load Sharing Approach

    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 theoverhead 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 thenodes. 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.

    The design of a load sharing algorithms require 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 assignments policies and the migration limiting policies for

    load-sharing algorithms are the same as that of load-balancing algorithms.

    6. Describe the clock synchronization algorithms and distributed algorithms in the context of

    synchronization.

    Ans:

    Clock Synchronization Algorithms

    Clock synchronization algorithms may be broadly classified as Centralized and Distributed:

    Centralized Algorithms

    In centralized clock synchronization algorithms one node has a real-time receiver. This node,

    called the time server node whose clock time is regarded as correct and used as the reference

    time. The goal of these algorithms is to keep the clocks of all other nodes synchronized with the

    clock time of the time server node. Depending on the role of the time server node, centralized

    clock synchronization algorithms are again of two types Passive Time Sever and Active Time

    Server.

    1. Passive Time Server Centralized Algorithm: In this method each node periodically sends a

    message to the time server. When the time server receives the message, it quickly responds witha message (time = T), where T is the current time in the clock of the time server node. Assume

    that when the client node sends the time = ? message, its clock time is T0, and when it receives

    the time = T message, its clock time is T1. Since T0 and T1 are measured using the same

    clock, in the absence of any other information, the best estimate of the time required for the

    propagation of the message time = T from the time server node to the clients node is (T1-

    T0)/2. Therefore, when the reply is received at the clients node, its clock is readjusted to T +

  • 7/30/2019 Mc0085 Solve

    7/8

    (T1-T0)/2. 2. Active Time Server Centralized Algorithm: In this approach, the time server

    periodically broadcasts its clock time (time = T). The other nodes receive the broadcast

    message and use the clock time in the message for correcting their own clocks. Each node has a

    priori knowledge of the approximate time (Ta) required for the propagation of the message time

    = T from the time server node to its own node, Therefore, when a broadcast message is received

    at a node, the nodes clock is readjusted to the time T+Ta. A major drawback of this method is

    that it is not fault tolerant. If the broadcast message reaches too late at a node due to some

    communication fault, the clock of that node will be readjusted to an incorrect value. Another

    disadvantage of this approach is that it requires broadcast facility to be supported by the network.

    2. Another active time server algorithm that overcomes the drawbacks of the above algorithm

    is the Berkeley algorithm proposed by Gusella and Zatti for internal synchronization of clocks of

    a group of computers running the Berkeley UNIX. In this algorithm, the time server periodically

    sends a message (time = ?) to all the computers in the group. On receiving this message, each

    computer sends back its clock value to the time server. The time server has a priori knowledge of

    the approximate time required for the propagation of a message from each node to its own node.Based on this knowledge, it first readjusts the clock values of the reply messages, It then takes a

    fault-tolerant average of the clock values of all the computers (including its own). To take the

    fault tolerant average, the time server chooses a subset of all clock values that do not differ from

    one another by more than a specified amount, and the average is taken only for the clock values

    in this subset. This approach eliminates readings from unreliable clocks whose clock values

    could have a significant adverse effect if an ordinary average was taken. The calculated average

    is the current time to which all the clocks should be readjusted, The time server readjusts its own

    clock to this value, Instead of sending the calculated current time back to other computers, the

    time server sends the amount by which each individual computers clock requires adjustment,

    This can be a positive or negative value and is calculated based on the knowledge the time serverhas about the approximate time required for the propagation of a message from each node to its

    own node.

    Centralized clock synchronization algorithms suffer from two major drawbacks:

    1. They are subject to single point failure. If the time server node fails, the clock

    synchronization operation cannot be performed. This makes the system unreliable. Ideally, a

    distributed system, should be more reliable than its individual nodes. If one goes down, the rest

    should continue to function correctly.

    2. From a scalability point of view it is generally not acceptable to get all the time requests

    serviced by a single time server. In a large system, such a solution puts a heavy burden on that

    one process.

    Distributed Algorithms

    We know that externally synchronized clocks are also internally synchronized. That is, if each

    nodes clock is independently synchronized with real time, all the clocks of the system remain

    mutually synchronized. Therefore, a simple method for clock synchronization may be to equip

    each node of the system with a real time receiver so that each nodes clock can be independently

    synchronized with real time. Multiple real time clocks (one for each node) are normally used for

  • 7/30/2019 Mc0085 Solve

    8/8

    this purpose. Theoretically, internal synchronization of clocks is not required in this approach.

    However, in practice, due to inherent inaccuracy of real-time clocks, different real time clocks

    produce different time. Therefore, internal synchronization is normally performed for better

    accuracy. One of the following two approaches is used for internal synchronization in this case.

    1. Global Averaging Distributed Algorithms: In this approach, the clock process at each node

    broadcasts its local clock time in the form of a special resync message when its local time

    equals T0+iR for some integer I, where T0 is a fixed time in the past agreed upon by all nodes

    and R is a system parameter that depends on such factors as the total number of nodes in the

    system, the maximum allowable drift rate, and so on. i.e. a resync message is broadcast from

    each node at the beginning of every fixed length resynchronization interval. However, since the

    clocks of different nodes run slightly different rates, these broadcasts will not happen

    simultaneously from all nodes. After broadcasting the clock value, the clock process of a node

    waits for time T, where T is a parameter to be determined by the algorithm. During this waiting

    period, the clock process records the time, according to its own clock, when the message was

    received. At the end of the waiting period, the clock process estimates the skew of its clock withrespect to each of the other nodes on the basis of the times at which it received resync messages.

    It then computes a fault-tolerant average of the next resynchronization interval.

    2. The global averaging algorithms differ mainly in the manner in which the fault-tolerant

    average of the estimated skews is calculated. Two commonly used algorithms are: 1. The

    simplest algorithm is to take the average of the estimated skews and use it as the correction for

    the local clock. However, to limit the impact of faulty clocks on the average value, the estimated

    skew with respect to each node is compared against a threshold, and skews greater than the

    threshold are set to zero before computing the average of the estimated skews. 2. In another

    algorithm, each node limits the impact of faulty clocks by first discarding the m highest and m

    lowest estimated skews and then calculating the average of the remaining skews, which is thenused as the correction for the local clock. The value of m is usually decided based on the total

    number of clocks (nodes).