[go: up one dir, main page]

0% found this document useful (0 votes)
86 views5 pages

Ct-2 Assignment DS ECS805

This document contains a student's assignment submission for their Distributed Systems course. The assignment contains answers to 4 questions about Remote Procedure Calls, the sequence of events in an RPC, the phases of the three-phase commit protocol, and the benefits and working of optimistic concurrency control in distributed systems. The student provided detailed explanations and comparisons for each question in the assignment.

Uploaded by

Ayush jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views5 pages

Ct-2 Assignment DS ECS805

This document contains a student's assignment submission for their Distributed Systems course. The assignment contains answers to 4 questions about Remote Procedure Calls, the sequence of events in an RPC, the phases of the three-phase commit protocol, and the benefits and working of optimistic concurrency control in distributed systems. The student provided detailed explanations and comparisons for each question in the assignment.

Uploaded by

Ayush jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Faculty of Engineering and Computing Sciences

CT-2 Assignment Program: B.Tech (CS) Branch /Section:


B
Total Marks: 18 Semester: VIII
Faculty member: MANISH JOSHI Course Name: Distributed System
Submission Date: 01 May, 2020 Course Code: ECS805

Submitted By: AYUSH JAIN (TCA1609030)

Unit-III
Ques: 1 Differentiate Remote Procedure Call and local calls.
Answer:
Remote Procedure Call Local Procedure Call

 Remote procedure calls are  Local are executed by the server


executed on another node of a hosting the program
network or computer.
 RPC is inter-process  LPC is to be used for
communication technique that communication between two user
allows client and server software mode processes.
to communicate in a distributed
environment.
 RPC is slower than LPC since it  LPC is faster than RPC since it is
uses the network to invoke the executed locally.
method.
 Called procedure need not exist in  Called procedure exist in the same
the same address space as the address space as the calling
calling procedure. procedure.

Ques: 2 Discuss sequence of events during remote procedure call?


Differentiate marshalling and unmarshalling to justify the procedure.
Answer:
The sequence of events in a remote procedure call are given as follows:

 The client stub is called by the client.


 The client stub makes a system call to send the message to the server and puts
the parameters in the message (Marshalling).
 The message is sent from the client to the server by the client’s operating system.
 The message is passed to the server stub by the server operating system.
 The parameters are removed from the message by the server stub
(Unmarshalling).
 Then, the server procedure is called by the server stub.

Marshalling VS Un-Marshalling :

Marshalling Un-marshalling

 It is the process of transforming the  It refers to the process of transforming a


memory representation of an object to representation of an object that is used
a data format suitable for the storage for storage or transmission to a
and transmission. representation of the object that is
executable.
 "Marshalling" refers to the process of  "Un-marshalling" is the reverse process
converting the data or the objects into of converting the byte-stream back to
a byte-stream. their original data or object. 
 Marshalling is the packing of  Un-marshalling is the unpacking of
arguments(or parameters) into a arguments (or parameters) received from
message packet the call packet.

 Marshalling means serialized.  Un-marshalling means de-serialized.


Unit-IV

Ques: 3 List different phases of three phase commit method.


Answer:

PHASE COORDINATOR COHORT

write prepare to work on transaction; when done, wait for


commit message to the log a prepare message

Receive message. When transaction is ready to


commit, write agree to commit (or abort) to log.
1
send prepare to
request
commit message
if timeout on waiting for a prepare message,
then abort

Wait for reply from all cohorts.

2 If all replies have been received


commit and all replies are "agree"
authorized messages, then write prepare-
to-commit message to the log.
Else if all replies are not wait for a prepare-to-commit or abort message
received before a timeout or at
least a single abort message is
received then write
an abort message to the log.

Send a prepare-to- If the cohort receives a prepare-to-


commit or abort message to all commit message, it sends back an
cohorts. acknowledgement and waits. The commit does
not yet take place.

If the cohort receives an abort message or times


out waiting for a message from the coordinator,
then it aborts the transaction. This means that it
releases all locks & resources, and reverts the
state of the data it modified.

If a prepare-to-commit was
sent, then wait for all cohorts to
respond.
Otherwise, we're done.

Write commit message to the
wait for a commit message
log.

Receive a commit. Release all locks & resources,


make database changes permanent.
If a timeout on waiting for a commit message,
send commit message then commit anyway.

3
commit finalized Send a commit completed message.

Receive commit
completed messages from all
cohorts. Give up waiting after a
certain time.

Clean up all state. Done.

Ques: 4 Give the benefits of using Optimistic Concurrency Control in


distributed system and discuss the working of its different phases.
Answer: In systems with low conflict rates, the task of validating every transaction for
serializability may lower performance. In these cases, the test for serializability is
postponed to just before commit. Since the conflict rate is low, the probability of
aborting transactions which are not serializable is also low. This approach is called
optimistic concurrency control technique.
Benefits of Optimistic Concurrency Control:
 The waiting time to Read a resource is very low.
 Deadlocks can be very easily recovered (by Validation phase).
 Read-only transactions can run concurrently with updating transactions without
loss of database consistency.
 Never lead to cascaded aborts.
 Maximum parallelism.
 Non-blocking: It is Simple to implementation on blocking.
 No mutual blocking between transactions results in a deadlock free.

Working of different phases:


There are three phases to an optimistic concurrency control protocol:

1. Read Phase:
The transaction reads the values of all data items it needs from the database and
stores them in local variables. Updates are applied to a local copy of the data and
announced to the database system by an operation named pre-write.
2. Validation Phase:
The validation phase ensures that all the committed transactions have executed
in a serializable fashion. For a read-only transaction, this consists of checking that
the data values read are still the current values for the corresponding data items.
For a transaction that contains updates, validation consists of determining
whether the current transaction leaves the database in a consistent state, with
serializability maintained.
3. Write Phase:
This follows the successful validation phase for update transactions. During the
write phase, all changes made by the transaction are permanently stored into the
database. The idea behind optimistic concurrency control is to do all the checks at
once; hence, transaction execution proceeds with a minimum of overhead until
the validation phase is reached. If there is little interference among transactions,
most will be validated successfully. However, if there is much interference, many
transactions that execute to completion will have their results discarded and
must be restarted later. Under these circumstances, optimistic techniques do not
work well. The techniques are called "optimistic" because they assume that little
interference will occur and hence that there is no need to do checking during
transaction execution.

THANK YOU

You might also like