Write modified version of transfer that avoids deadlock, Database Management System

Assignment Help:

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.


Related Discussions:- Write modified version of transfer that avoids deadlock

Relationship, what is the relationship between receipt and owner entities i...

what is the relationship between receipt and owner entities in computer sales and service company

Er database theoretical and modeling database system, Need an expert in ER ...

Need an expert in ER database theoretical and modeling database system Project Description: Need an expert in ER database theoretical and modeling database systems? Skills

single products ordered, For Colorado customers calculate the number of si...

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

Approach to implement traffic data management, There are many simple and co...

There are many simple and complex approaches to implement. These reports are based on some views or certain query. The following number of reports can be built. 1. The averag

Mis, explain various steps uses in evaluation and maintenance of MIS.

explain various steps uses in evaluation and maintenance of MIS.

Need vmware technical support, Project Description: Critical Project for...

Project Description: Critical Project for VMware Technical support. VMWare ESXi 5.1 support for upgradation and migration problem. Technical expert of Vmware needed. Sk

Which is another name for weak entity, Which is another name for weak entit...

Which is another name for weak entity? Child is another name of weak entity.

Data control, Data Control The data control mostly refers to commands that...

Data Control The data control mostly refers to commands that permit system and data privileges to be passed to several users. These commands are usually available to database admi

Physical records, Physical Records These are the records that are store...

Physical Records These are the records that are stored in the secondary storage devices. For the database relation, physical records are the group of fields kept in adjacent me

Explain two phase locking protocol, Explain Two phase locking protocol ...

Explain Two phase locking protocol A transaction is consider as to follow the two-phase locking protocol if all locking operations precede the first unlock operation in the tra

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd