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

Queries, Write a query that display ename annual salary and comm from emp t...

Write a query that display ename annual salary and comm from emp table

What is horizontal fragmentation, What is horizontal fragmentation? Hor...

What is horizontal fragmentation? Horizontal fragmentation divides the relation by assuming every tuple of r to one or more fragments

Dbms built for online transaction processing, Problem: A DBMS built for...

Problem: A DBMS built for Online Transaction Processing (OLTP) is usually regarded as unsuitable for data warehousing. Each system is designed with a different set of requireme

The advantages of a database management system, The advantages of a databas...

The advantages of a database management system (DBMS) include :- Data integrity and elimination of duplication.

Project, Preliminary entities and attributes of human resourse management d...

Preliminary entities and attributes of human resourse management database management system

Boyce-codd normal form (bcnf), Boyce-Codd Normal Form (BCNF) The relati...

Boyce-Codd Normal Form (BCNF) The relation NEWSTUDENT (Enrolmentno, Sno, Sname, Cname, Cno,) has every attributes participating in candidate keys as all the attributes are assu

What is transaction, What is transaction? Transaction is a unit of prog...

What is transaction? Transaction is a unit of program implementation that accesses and possibly updated several data items.

Sql insert statements, Submit SQL INSERT Statements that will populate the ...

Submit SQL INSERT Statements that will populate the database with sample data.  You must insert at least 5 records into each table in your database.Submit your SQL INSERT Statement

Identify the candidate keys, Consider the following six relation schemes an...

Consider the following six relation schemes and their corresponding sets of functional dependencies. In each case identify a. All the candidate keys b. The highest normal for

Benefits of views-data control, Benefits: It limits data access. ...

Benefits: It limits data access. It makes difficult queries look easy. It permits data independence. It presents dissimilar views of the similar data.

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