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
Fragmentation: It is definite as partitioning of a relation into various fragments.Every fragment can be stored at a dissimilar site.

What are the advantages of relational data model? Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer

What does the extract statement do in extract datasets? The data is written to virtual memory by extract commands.

We need help in Booking System for Golf Business Development of a web based booking system which permits clients to book golf lessons with the following features- a) 4 user p

Consider the two relations given below Given that A is the primary key of R, D is the primary key of S and there is a referential integrity among S.A and R.A, discuss all

Explain the Object-oriented decomposition Object-oriented decomposition targets at identifying individual sovereign objects that encapsulate both a state and certain behavio

What is key ? Key - A single attribute or a combination of two or more attributes of an entity set which is used to recognize one or more instances (rows) of the set (table) is

Find out the names and company names of all employees sorted in ascending order of company name and descending order of employee names of by which company. SELECT EMPLOYEE_NAME,

Define Sequence A sequence is a set of integers 1, 2, 3 that are generated in order on demand. Sequences are regularly used in databases because lots of applications require ev

Why DML is used for? DML is used to Manipulation and processing of database. DML is provided for manipulation & processing of database. (Data stored in the database is processed