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
Determine the Persistent object Persistent object can be stored in one of the following: Files Cheap, permanent, simple storage Low level (Write, Read) Ap

What do you mean by an execution plan? Why is it used? How will you view it? a.) An execution plan can be known as a road map which textually or graphically illustrates the dat

What is OLAP? OnLine Analytical Processing (OLAP) is a Business Intelligence (BI) reporting system. OLAP gives the user with the capability to sum, count, average and do other


Define lock? Lock is the most common used to execute the requirement is to permit a transaction to access a data item only if it is currently holding a lock on that item.

What are the basic objects of the data dictionary? Tables Domains Data elements Structures Foreign Keys

What is known as a search key? An attribute or set of attributes used to look up records in a file is known as a search key.

Explain the Object-oriented decomposition Object-oriented decomposition targets at identifying individual sovereign objects that encapsulate both a state and certain behavio

Increases efficiency : Data is stored close to most often used site, therefore retrieval would be faster. Also, data that is not required by local applications is not stored, there

What are the aggregate objects in the data dictionary? Views Match codes Lock objects.