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
1.Suppose you are given a dataset that consists of a random sample of tasters, on which the following variables were obtained: (y) Zpref = taste preference for green beans store

Design a gennalization and specialization hierarchy for an automobile sales company

Define a table in SQL known as Client that is used to store information about the clients. Define CLIENT_NO as the primary key whose first letter must begin with ‘C'. Also ensure t

DROP TABLE Command: When an existing object is not needed for further use, it is always better to eliminate it from the database. To remove the existing object from the databas

Explain outer join? Outer Join - If there are any values in one table which do not have corresponding value(s) in the other, in an equi-join which will not be chosen. Such ro

Describe Application programming interface? Application Programming Interface - Commercial SQL implementations take one of the two primary techniques for involving SQL in a p

Question: Consider the following database relations for a textbook ordering system used by a college bookshop: Book (b-copy#, bname, ISBN#, author, price, subject) Order (s#


What are the reasons of bucket overflow? Explain any two methods for solving this problem. Ans:  It is general for file structures to be divided into equal-length partitions, k

Extend your CREATE TABLE statement from problem 3 with referential integrity constraints. Updates and deletes on related rows are restricted. 6. From examination of the sample data