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

Explain recovery process after system failure, Explain recovery process aft...

Explain recovery process after system failure using checkpoint. Ans: Checkpoint scheme or method is an extra component of the log based recovery system. This scheme is used to

What are the ways in which signal can be generated, What are the ways in wh...

What are the ways in which signal can be generated A signal might be generated in many ways such as a Signal is result of particular physical condition. Whenever a process writ

What is data model, A Data Model in software engineering is an abstract...

A Data Model in software engineering is an abstract model that organizes and documents the business data for interaction between team members and is used as a plan for creating

Define the term- control as state within program, Control as State within P...

Control as State within Program 1.  The term control exactly means to check effect of input within a program. For illustration, in Figure, after the ATM card is inserted (a

Data definition language, Data Definition Language It organises the dat...

Data Definition Language It organises the data in the form of columns and rows. But what does the data field column of table accumulate? How do you describe it using SQL? Th

Concurrency control, Give the two reasons for allowing concurrency

Give the two reasons for allowing concurrency

What is data model explain object and data base models, What is data model?...

What is data model? Explain object based and record based data models? Ans: A data model is an abstract model in which describes how data is represented and accessed. (i)

Object query language and odmg schema , (a)    Provide the description of t...

(a)    Provide the description of the following ODMG schema in the Object Definition Language (ODL). (b)   Based on the above object database, write the following queries i

Checkpoint, what is check point in database management system

what is check point in database management system

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