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
Example - ALTER TABLE emp MODIFY (empno NUMBER (7));

Consider a systems development project with the following data Activity                                Duration (weeks)        Precedence Relationship 1. Software design

Define a job scheduling strategy that will meet business requirement of reporting availability by 6am CST for the following cubes? Show the job scheduling dependencies in a pictori

State the Steps of Object Design Object design is a very iterative process in which various classes, relationships among objects are added when you move from one level to

What is the use of Union and intersection operation? Union: The result of this operation contains all tuples that are either in r1 or in r2 or in both r1 and r2.Duplicate tuple

What is a PROJECT operation? The project operation is a unary operation that returns its argument relation with particular attributes left out. Projection is shown by pie (π).

What is the difference between WHERE and HAVING clauses?. Predicates in the WHERE clause applies to every tuple while the predicate in the HAVING clause applies to groups.

Package classes and associations into models  Programs are made of separate physical units which could be edited, imported, complied or otherwise manipulated. The careful part

Define data model? A data model is a collection of conceptual tools for explaining data, data relationships, data semantics and consistency constraints.