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 Alternate Key Alternate Key: This is the candidate key which is not taken as the primary key of the table. They are named so because although not the primary key, the


Project Description: I need a point of sale for motels. It needs to run on windows and requires being network able so that we can have more than one computer using it at once.

What is E-R model? This data model is based on real world that having of basic objects called entities and of relationship between these objects. Entities are explained in a da

What are the ways in which signal can be generated A signal might be generated in many ways such as a Signal is result of particular physical condition. Whenever a process writ

Consider the relations given below Borrower (id_no, name) Book (accno., title, author, borrower_idno) (a) Define the above relations as tables in SQL forming real world assumptio

A table joined with itself is called ? A table joined with itself is known as self join table. Normal 0 false false false EN-IN X-NONE X-NONE

What are the responsibility of File manager? File Manager : Manager allocation of space on disk storage and the data structures used to represent within stored on disk. It is a

What are audit trails? An audit trail is a log of all alters to the database along with information like which user performed the change and when the alter was performed.

What is a records management consultation? Our organization is an authority for disseminating your specific requirements and giving you with a solution to effectively manage yo