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

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.

Posted Date: 3/18/2013 6:19:54 AM | Location : United States







Related Discussions:- Write modified version of transfer that avoids deadlock, Assignment Help, Ask Question on Write modified version of transfer that avoids deadlock, Get Answer, Expert's Help, Write modified version of transfer that avoids deadlock Discussions

Write discussion on Write modified version of transfer that avoids deadlock
Your posts are moderated
Related Questions
Hashed File Organisation Hashing is the most common form of purely random access to a database or file. It is also used to access columns that do not have an index as an optimi

Explain Two phase locking protocol A transaction is consider as to follow the two-phase locking protocol if all locking operations precede the first unlock operation in the tra

DISADVANTAGES OF RDBMS

In the architecture of a database system which external level used? In the architecture of a database system view external level used.

Explain the paths in the association network We can analyze use of paths in the association network as given below: Calculate each operation Find associations whic

Entity types that do not have any key attribute, and therefore cannot be identified independently, are known as weak entity types. A weak entity can be recognized uniquely only by

Ask question #MinimRead Dennis et al. Chapter 6: Minicase 2. Work through it and answer the questions. See the attached example. SequenceDiagram.png Based on the structural mod

In an organisation various projects are undertaken. Each projects can employ one or more employees. Every employee can work on one or more projects. Each project is undertaken on

In a Hierarchical model of data records are organized ? In the hierarchical model of data records are organized as Tree structure.

What are the different integrity constraints in RDBMS? The various integrity constraints in RDBMS are as: Primary Key: primary key is a grouping of one or more attributes