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

State The position of object at any moment is called state. An object can have many states depend upon time. After receiving some input instructions, the object can change its

For Colorado customers calculate the number of single products ordered. If a product is purchased on multiple orders, it should be counted only single time. The result should conta

Consider the following relational schema: PERSON (SS#, NAME, ADDRESS) CAR (REGISTRATION_NUMBER, YEAR, MODEL) ACCIDENT (DATE, DRIVER, CAR_REG_NO) OWNS (SS#, LICENSE) Constru

Can you assist me in Database management system? I need help in my courses, please email me at and get back me soon...


What are called index-sequential files? The files that are ordered sequentially with a primary index on the search key are known as index-sequential files

Depending upon the rules we have found, we can classify the locks into two types. Shared Lock: A transaction might be acquiring shared lock on a data item in order to read it

Question A What is operational intelligence? Question B What is Business Intelligence? Explain the components of BI architecture Question C Differentiate between databas

Ask Write the SQL code that will create the table structure for a table named EMP _1. This table is a subset of the EMPLOYEE table. The basic EMP_1 table structure is summarized in