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

Method of analyzing association traversal, Analyzing Association Traversal ...

Analyzing Association Traversal Till now, we have supposed that associations are bi-directional. But in the case of traversal, it is in only one direction in any application,

Insert - referential integrity, The insertion of a tuple in the aim of refe...

The insertion of a tuple in the aim of reference does not cause any destruction. Though, insertion of a tuple in the relation in which, we has the foreign key, for instance, in ASS

Explain projection operation distribute over union operation, Illustrate th...

Illustrate the statement 'Projection operation distributes over the union operation'. Give an example.    Ans: Π L (E 1 ∪ E 2 ) = (Π L (E 1 )) ∪ (Π L (E 2 ))   This says th

What is advantage of two-way association, What is advantage of two-way asso...

What is advantage of two-way association? Two-way association advantages are following: a) Independent of the classes. b) Useful for existing predefined classes that are

Define the term e-government, Question: (a) Define the term e-Governme...

Question: (a) Define the term e-Government and briefly explain, using appropriate examples, the aspects it covers. (b) Give four reasons as to why a country should adopt e

Consistency-transaction , Consistency: This property makes sure that a com...

Consistency: This property makes sure that a complete transaction implementation takes a database from one consistent state to another consistent state. If the transaction fails e

Sql queries, find a name whose address is erode from student table

find a name whose address is erode from student table

Name the various privileges in sql, Name the various privileges in SQL? ...

Name the various privileges in SQL? A) Delete B) Select C) Insert D) Update

Update operations in dbms - insert operation, Update Operations and Dealing...

Update Operations and Dealing with Constraint Violations There are three basic operations to be executes on relations: Insertion Deletion Update The INSER

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