Docsity

CSEP 545 Assignment: Analyzing ACID Properties of Transactions using B1, Exercises of Fundamentals of E-Commerce

Toggle sidebar
bg1
Assignment 1
CSEP 545
•/* Start new transaction */
int start()
Returns: -1, if there is an active transaction
tId > 0 (a new Transaction Identifier) otherwise
•/* If possible, read block at blockAddr on behalf of transaction tId
from disk into main memory and save a pointer to it in block */
int read(int blockAddr, int tId, int *block)
Returns: 0 if successful, -1 otherwise
•/* tell B1 that transaction tId has updated a block at blockAddr */
int write(int blockAddr, int tId)
Returns: 0 if there is no cached entry for blockAddr
1 otherwise
•/* Try to commit transaction tId */
int commit(int tId)
Returns: 0 if successful, -1 otherwise
•/* Abort transaction tId */
int abort(int tId)
Returns: 0
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download CSEP 545 Assignment: Analyzing ACID Properties of Transactions using B1 and more Exercises Fundamentals of E-Commerce in PDF only on Docsity!

Assignment 1

CSEP 545

Start new transaction

int start() Returns:

if there is an active transaction tId

(a new Transaction Identifier) otherwise

If possible, read block at blockAddr on behalf of transaction tId from disk into main memory and save a pointer to it in block

int read( int blockAddr, int tId, int *block) Returns:

if successful,

otherwise

tell

B

that transaction tId has updated a block at blockAddr

int write( int blockAddr, int tId) Returns:

if there is no cached entry for blockAddr 1 otherwise

Try to commit transaction tId

int commit( int tId) Returns:

if successful,

otherwise

Abort transaction tId

int abort( int tId) Returns:

lastTrans = 1; ... int

start()

{ if

(lastTrans < 0)

return

else

lastTrans = -(++lastTans);

return

lastTrans;

Start

Write

/* A transaction should call

write(&Cache(e).newBlock, tId)after it updates Cache(e).newBlock. */

int

write(

int

blockAddr,

int

tId)

/* find the cache entry e for block blockAddr */ if

(there is no such entry)

return

else

Cache(e).tId = tId; return

Commit

int

commit(

int

tId)

for

(each cache

entry e where Cache(e).tId == tId)

status

= diskWrite(Cache(e).blockAddr, &Cache(e).newBlock);

Cache(e).tId = - tId;

if

(status == -1)

Abort(tId);

return

} for

(all cache entries e) set Cache(e).tId = 0;

lastTrans = -lastTrans;

return

Questions

For each of the scenarios below, analyze whether

transactions that use B1 satisfy the four ACIDproperties.

a.

The OS and B1 never crash. Transactions run serially.

b.

The operating system can crash, in which case mainmemory is lost. Transactions run serially.

c.

The operating system and B1 never crash. Transactionsrun serially. But if DiskWrite(b, addr) returns 0 then itmight have corrupted block b on disk.variation of (c): If DiskWrite(b, addr) returns

then it

might have corrupted block b on disk.

d.

The operating system and B1 never crash. Twotransactions are allowed to run concurrently.