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

Objectives-the structured query language, Objectives After reading this...

Objectives After reading this part, you should be able to: Modify, create, and delete database schema objects; Update database using SQL command; Retrieve data f

Create an index for the table client, Create an index for the table Client,...

Create an index for the table Client, field CLIENT_NO of Q ? Command:   CREATE INDEX client_client_no ON client(client_no);

Objectives of data management, The traffic data mgmt. systems infrastructur...

The traffic data mgmt. systems infrastructure plan describes the software, hardware, data network, and other elements that will support the TDMS. The infrastructure plan is based o

Transaction, .#question. Discuss the problem which may arise during concurr...

.#question. Discuss the problem which may arise during concurrency control and recovery in distributed database which are not encountered in controlized database environment.

Mapping, external and internal mapping with examples

external and internal mapping with examples

ERD, online eductional management system ke diagram

online eductional management system ke diagram

Derived horizontal fragmentation, Derived horizontal fragmentation: Some ap...

Derived horizontal fragmentation: Some applications may include a join of two or more relations. If the relations are stored at dissimilar locations, there may be a major overhead

What are the benefits of document scanning, What are the benefits of docume...

What are the benefits of document scanning? Document scanning, in addition to being cost-efficient, also enhances productivity. This service enhances security as you set the pa

Design and building a distributed information system, prototype of a distri...

prototype of a distributed information system for a national car part retail outlet chain.

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