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
Types of data independence Data independence can be classified into the following two types: Physical Data Independence: This means that for any change made in the physi

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

Advantages And Drawbacks Of Ddbms  There are various reasons for building distributed database systems, with sharing of data, reliability and availability, and speedup of query

Nested Queries Let us see some more complex queries in this section. Sub-queries: Some of the basic concerns of sub-queries are: A sub-query is a SELECT statemen

Define query optimization. Query optimization refers to the process of search the lowest -cost method of evaluating a given query.

Define a property that is not a property of transactions? Ans: Concurrency is not a property of transactions

intent locking

Define check point and its impact on data base recovery.                  Ans:  There could be hundreds of transactions handled per minute, in a large on-line database system.

Determine the minimal set of functional dependencies for the following data. This table is part of the OHSU database of extracurricular activities and tracks the DMICE band's co

File Organisation In Dbms Introduction Databases are used to store information. Usually, the principal operations we have to perform on database are those relating to: