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
what is cascading rollback

Q. Describe how an ER schema can be represented by relation schemas and constraints arising from ER design can be mapped to constraints on a relation schema.     The entity rela

Every simple attribute of an entity type have a possible set of values that can be attached to it. This is known as the domain of an attribute. An attribute cannot have a value out

How Relational Calculus is different from Relational Algebra? What do understand by TRC queries and DRC queries?  Ans: Relational calculus contain two calculi, the tuple relati

What is horizontal fragmentation? Horizontal fragmentation divides the relation by assuming every tuple of r to one or more fragments

Adding Redundant Associations for Efficient Access The expression redundant association means using "duplicate association for proficient access". While analysis, it is not a

A file manipulation command that extracts some of the records from a file is called ? A file manipulation command that extracts some of the records from a file is called SELECT

System error :These contain errors in database system or the OS, example, deadlocks.Such errors are fairly hard to detect and need reprogramming the erroneous components of the sys

Write short note on Events Events consist of inputs, interrupts, decisions and actions performed by any external device or users. Every event always has a sender and receiver.

Explain the Log Based Recovery Method? The system log that is generally written on stable storage consists of the redundant data required to recover from volatile storage failu