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

What is the function of sql server agent windows service, What is the funct...

What is the function of SQL Server Agent Windows service? - It's a Windows service that handles tasks scheduled within SQL Server environment. These tasks are also known as job

Data dictionary, The database is to record information about artists for a ...

The database is to record information about artists for a (music) production company. An artist is the name of a singer or band; the name of the artist, the year the artist started

Physical location of record is determined by which formula, The physical lo...

The physical location of a record is determined by which mathematical formula that transforms a file key into a record location? The physical location of a record is determined

When is a transaction rolled back, When is a transaction rolled back? A...

When is a transaction rolled back? Any changes that the aborted transaction made to the database must be uncompleted. While the changes caused by an aborted transaction have be

Assigning responsibility for operation, Assigning Responsibility for Operat...

Assigning Responsibility for Operation Many operations might have obvious target objects, but some of these operations could be used at numerous places in an algorithm, by one

Checkpoint, what is check point in database management system

what is check point in database management system

What are the uses of functional dependencies, What are the uses of function...

What are the uses of functional dependencies? To test relations to see whether they are legal under a given set of functional dependencies. To state constraints on the set

RDBMS, Benefits and limitations

Benefits and limitations

Limitations of file based system, Limitations of File Based System The...

Limitations of File Based System The file-based system has some limitations. The limitations are listed as follows: Isolation and separation of data: When the data is

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