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

Use Delegation to Share Implementation The delegation " Delegation comprises of catching an operation on one object and sending it to other object which is part, or related to

Draw entity relationship diagram for the following scenario. A university has many departments whereas each department belongs to that particular uni. That uni has also many bui


Describe the algorithm to draw the dependency graph?   Ans: Algorithm to draw Precedence Graph is like this: a.  For every transaction T i participating in schedule S, make

A database will be made to store information about patients in a hospital. On arrival, each patient’s personal details (name, address, and telephone number) are recorded where poss

What is Normalization? Database normalization is a data design and organization method applied to data structures based on rules that help building relational databases. In rel

Explain Clustering file organization (i) Determine if a record of file is physically ordered on a nonkey field - that does not comprise a different value for each record - that

Structure of Client Server Systems: In client/server architecture, clients show users who require services while servers give services. Both client and server are a combination of

Example : Search the name, department number and salary of employees drawing minimum salary in that department. SELECT ENAME, SAL, DEPTNO  FROM EMP WHERE SAL IN (SELECT MI