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
Question (a) Visual Basic is governed by an event processor. Explain the meaning of this phrase. (b) Differentiate between an general procedure and event procedure. (c)

The database application project (DAP) for this assignment consists of the creation of a fully functional Microsoft Access database application for a real client. I recommend you s

Define a view and a trigger. Construct a view for the above relations that have the information about suppliers and the elements they supply. The view holds the S#, SNAME, P# , PNA

What is the difference between SQL Server 2000 clustered and nonclustered indexes? With a clustered index, the data are kept in the bottom level of the index and in the similar

Differance between DDL and SDL? DDL and SDL - The data definition language (DDL) is used through DBA and database designers to describe internal schema, conceptual schema, and

What is an object ID? Each class-derived table has an ID for primary key, one or more object IDs form primary key for association derived tables. An object ID is equivalent dat

Explain Foreign Key? Foreign Key - Let there are two relations (tables) R and S. Any candidate key of the relation R that is referred within the relation S is known as the fo

Define Deadlock avoidance These protocols as well ensure that the system will never enter a deadlock state although the way it is done is different from deadlock prevention. I

#questiononsider the following relation: CAR_SALE =(CAR_ID,oPTION_TYPE, Option_listpreice, Sale_date, Option_discountedprice)..

explain at least five widly used case tools