Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Theory Assignment 1

ACS – 2023
Mats Pieter Buis – wmq295
Rune Brix Lundsgaard Thomsen – crp664
William Frydendal Gercke – wvl774
Deadline: December 7 at 23:59

1
1.1
The latency when running a program concurrently compared to sequentially can be thought
of as

ℓC (P ) max P + cC
=P , cC ≥ cS
ℓS (P ) p∈P p + cS

where the subscript C denotes concurrent execution, the subscript S denotes sequential
execution, ℓ(P ) denotes the latency of a program P comprising its constituent processes
and c denotes overhead. Concurrency may thus only increase latency if cC is sufficiently
large relative to cS such that the fraction is greater than 1.

1.2
Say a program is stuck in a bottleneck — other requests cannot be sent before a single
request which is taking longer than the others to process is sent. Imagine a good which, if
a web store’s supply of it runs out, an immediate resupply will be prompted given that the
good would still be able to be sold at a profit. Batching in this case would be combining
messages into one before reporting the ‘amount in stock’ — given that the web store is
willing to supply this information — while dallying would be delaying a message reporting
that ‘in stock’ = FALSE because of the likelihood that another process resupplies before
the slow process terminates (or the slow process could be the resupply).

1
1.3
Imagine a food delivery app in which a customer can check their order status — it may
be ‘accepted’ or ‘rejected’. The food delivery app initially queries the restaurant and the
restaurant eventually responds after which the food delivery app caches the result of the
query since an anxious customer might check several times and it is very rare that the
restaurant rejects the order after initially accepting it — the delivery app thus does not
query the restaurant every time the customer checks their order status. This fast path
optimization reduces latency while sacrificing a small amount of accuracy.

2
2.1
Using a hashed distribution of addresses across the cluster machines. Each machine is
assigned a range of addresses based on a hashed function. The hashed distribution in
address mapping enhances efficiency by minimizes the need for centralized control. We
do this by distributing memory addresses across multiple machines, which in turn reduces
the likelihood of any single machine becoming a bottleneck. This approach also adds fault
tolerance, by securing that if one machine fails, only a portion of the address space is
affected, and the system can still function. Decentralized components also reduces the risk
of a single point of failure.

2.2
The READ function: Translates a global address to a machine specific address and retrieves
data from the identified machine.
f u n c t i o n READ( g l o b a l a d d r e s s ) :
machine id , l o c a l a d d r e s s = t r a n s l a t e a d d r e s s ( g l o b a l a d d r e s s )
r e t u r n communicate with machine ( machine id , ' read ' , l o c a l a d d r e s s )
The WRITE function: Translates a global address to a machine-specific address and writes
data to the identified machine.
f u n c t i o n WRITE( g l o b a l a d d r e s s , data ) :
machine id , l o c a l a d d r e s s = t r a n s l a t e a d d r e s s ( g l o b a l a d d r e s s )
communicate with machine ( machine id , ' w r i t e ' , l o c a l a d d r e s s , data )
The ”translate address function converts a global address into a machine specific address
and a local address withing that machine. We communicate with individual machine
with the ”communicate with machine” function, which sends the appropriate read of write
command along with the local address and data if needed.

2
2.3
We use atomicity in the READ/WRITE operations to ensure data consistency in a distributed
memory system. We achieve this when multiple clients access the system concurrently,
by implementing a distributed locking mechanism or a multi-version concurrency control.
These two methods manage concurrent accesses by ensuring that conflicting operations
are serialized, thus preserving the atomic nature of each operation and maintaining overall
system integrity.

2.4
In order to handle machines entering and leaving the system we need a flexible and resilient
naming mechanism. This needs a distributed directory service that can efficiently handle
dynamic address mapping and updates. To tolerate faults related to dynamic naming,
the directory service should be replicated across multiple machines ensuring continuous
operation and data availability even in the event of machine failures or network issues.

T1 T1 T1

T3 T2 T3 T2 T3 T2

1. No, it is not conflict serializable because there is a cycle in the precedence graph.

2. Yes it is conflict serializable because there are no cycles in the precedence graph.

3. Yes, it is conflict serializable because there are no cycles in the precedence graph.

Schedule 1:

No, it could not have been generated by strict 2SPL because T1 gets a shared lock for
X since it has to READ X. Consequently, T2 will get an exclusive lock on Z and it will want
to acquire an exclusive lock on X but it cannot because T1 has not committed yet since it
still has to WRITE on Y.
Schedule 2:

T1: S(X)R(X) X(Y)W(Y) C U(X,Y)


T2: S(Z)R(Z) X(X)W(X)X(Y)W(Y) C U(X,Y,Z)
T3: X(Z)W(Z) C U(Z)

3
where S denotes obtaining a shared lock, X denotes obtaining an exclusive lock and U
denotes a release of locks.
Schedule 3:

No, it could not have been generated by strict 2SPL because T1 has an exclusive lock
on X and T2 also wants to WRITE on X which is not possible since T1 still has the exclusive
lock on X because it first has to perform the operation W(X) before it will commit and
release the exclusive lock on X.

4
To determine if transaction T3 should commit or roll back under the Kung-Robinson opti-
mistic concurrency control model in each scenario, we need to consider the READ and WRITE
sets of completion times and whether T3’s operations conflict with those of T1 and T2.

• Scenario 1: T3 should be rolled back. T3’s READ set includes object 3, which is also
in T1’s WRITE set. Since T1 completes before T3 starts, T3’s READ of object 3 is
invalidated by T1’s WRITE.

• Scenario 2: T3 can commit. Although T3’s READ set overlaps with T1 and T2’s READ
sets, there is no conflict with T1 and T2’s WRITE sets. T1 WRITEs to object 3, which is
in T3’s READ set, but this is not a conflict as T1 completes before T3 starts its WRITE
phase.

• Scenario 3: T3 should be rolled back. T3’s WRITE set includes objects 7 and 8 which
conflicts with T2’s READ set. Since T2 completes its READ phase before T3 does, T3’s
WRITE to objects 7 and 8 invalidates T2’s READ.

You might also like