Write modified version of transfer that avoids deadlock, Database Management System

Assignment Help:

Your OS has a set of queues, each of which is protected by a lock. To enqueue or dequeue an item, a thread must hold the lock associated to the queue.

You need to implement an atomic transfer routine that dequeues an item from one queue and enqueues it on another. The transfer must appear to occur atomically.

This is your first attempt:

void transfer(Queue *q1, Queue *q2) {

Item thing; /* the thing being transferred */

q1->lock.Acquire(); thing = q1->Dequeue(); if (thing != NULL){

q2->lock.Acquire(); q2->Enqueue(thing); q2->lock.Release();

} q1->lock.Release()

You may assume that q1 and q2 never refer to the same queue. Also, assume that you have a function Queue::Address that takes a queue and returns, as an unsigned integer, its address in memory.

a. Explain how using this implementation of transfer leads to deadlock; b. Write a modified version of transfer that avoids deadlock and does the transfer atomically; c. If the transfer does not need to be atomic, how might you change your solution to achieve a higher degree of concurrency? Justify how your modification increases concurrency.


Related Discussions:- Write modified version of transfer that avoids deadlock

Explain the two types of participation constraint, Explain the two types of...

Explain the two types of participation constraint.  Total: The participation of an entity set E in a relationship set R is said to be total if each entity in E participates i

Read-set(t) and timestamps-optimistic concurrency contents, read-set(T) : E...

read-set(T) : Each data items that are read by a transaction T Timestamps : for all transaction T, the start-time and the end time are reserved for all the three phases.

Although how will the system recover, Although how will the system recover ...

Although how will the system recover The selection of REDO or UNDO for a transaction for the recovery is completed on the basis of the state of the transactions. This state is

Define multivalued dependency, Define multivalued dependency.  What do unde...

Define multivalued dependency.  What do understand by trivial multivalued dependency?  Ans: A multivalued dependency is a full constraint among two sets of attributes in a rela

What is data independence, What is data independence? Data Independenc...

What is data independence? Data Independence: Techniques which permit data to be changed without affecting the applications in which procedure it. There are two types of data

Briefly describe concurrency execution, Briefly describe concurrency execut...

Briefly describe concurrency execution? Lock - based protocols Locks There are several modes in which a data item may be locked in this section we restrict our attention

Homework help, Draw an entity relationship diagram (ERD) for the following ...

Draw an entity relationship diagram (ERD) for the following situation: A company has a number of employees. Each employee is identified by an Employee_Id. The company wants to st

Managing database, 10A.53 Code an Oracle Database trigger to enforce the ...

10A.53 Code an Oracle Database trigger to enforce the constraint that an employee can never change his or her department. 10A.54 Code an Oracle Database trigger to allow the

Explain tuple variable, Define tuple variable? Tuple variables are used...

Define tuple variable? Tuple variables are used for comparing two tuples in the same relation. The tuple variables are explained in the from clause by way of the as clause.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd