Question

For the readers & writers problem we discussed the solution to the readers-priority variant (where readers can keep entering the DB provided another reader is already there, and a writer must wait for all readers to exit on their own). What was the problem we discussed with this solution?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The problem with the readers-priority variant is that if the reader first arrives and get the access to the database, so until the reader is reading from the database the writer cannot write and will not be granted the access.

So, the writer here must wait and if some other readers also came to read the database and then writer must wait. Reader will get priority and writer will wait.

And if the new readers keep on arriving then, the writer will not be given the access to the database for writing. This situation will lead to starvation that is the indefinite blockage of the system.

To avoid this problem either give the writer priority or simply treat the reader writer in the order of their arrival or in first comes first serve order. This ordering solution is also sometimes termed as the fairness.

Giving the priority to the writer may cause readers starvation like that in case of reader’s priority, where writer starves.

The better solution is to treat them in their order of arrival.

The solution to the readers priority problem can be implemented by the use of message passing with wait and release request by using the following:

Order mutex: it avoids the deadlock and grants fair access to readers and writers.

Access mutex: it provides the access over the system and resources.

Add a comment
Know the answer?
Add Answer to:
For the readers & writers problem we discussed the solution to the readers-priority variant (where readers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In the class we mentioned briefly the readers-writers problem with writers priority. The problem can be solved in guard...

    In the class we mentioned briefly the readers-writers problem with writers priority. The problem can be solved in guarded commands as follows: void writer) void reader when writers-0 readers++ when (readers-0)&&(active writers0) active_writers++ /Iread //write [readers--] (writers-active writers- Here writers represents the number of threads that are either writing or waiting to write. The variable active_writers represents the number of threads (0 or 1) that are currently writing. In the class we mentioned briefly the readers-writers problem with writers priority....

  • 4. (20 points) In the class we mentioned briefly the readers-writers problem with writers priority. The problem can...

    4. (20 points) In the class we mentioned briefly the readers-writers problem with writers priority. The problem can be solved in guarded commands as follows: void writer) void reader --owriters when writers0 readers++i when (readers0)&&(active writers0) active writers++ //read //write [readers--1 [writers-- active writers-- Here writers represents the number of threads that are either writing or waiting to write. The variable active_writers represents the number of threads (0 or1) that are currently writing. Implement the solution using either POSIX threads...

  • Process Synchronization Assignment: Readers-Writers Problem . Consider readers and writers share a bounded array. ii. Writers...

    Process Synchronization Assignment: Readers-Writers Problem . Consider readers and writers share a bounded array. ii. Writers write an integer on the array. iii. Readers read and display contents of the array. iv. Writers will not be allowed to write if there is a reader reading the array. v. Only one writer can access the array at a time. But many readers can access the array at the same time. vi. All readers are blocked if there is a writer writing...

  • pleasw answer as soon as possible . this is for my exam practice . please read...

    pleasw answer as soon as possible . this is for my exam practice . please read the code and answer the question In a system, there are multiple reader processes which read from a shared file and multiple writer processes which update a shared file. The following variables are shared among all processes: int readCounter; semaphore mutex, writeLock; Reader and writer processes are given in the following C++-like pseudo programs: Reader Process // Non-Critical Section P(mutex); Writer Process // Non-Critical...

  • In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the...

    In class, we discussed the priority queue (PQ) ADT implemented using min-heap. In a min-heap, the element of the heap with the smallest key is the root of the binary tree. On the other hand, a max-heap has as root the element with the biggest key, and the relationship between the keys of a node and its parent is reversed of that of a min-heap. We also discussed an array-based implementation of heaps. In this assignment, your task is to...

  • 3. In class we discussed the heat conduction problem with the boundary conditions a(0, t) 0, t4(1...

    3. In class we discussed the heat conduction problem with the boundary conditions a(0, t) 0, t4(1,t)-0, t > 0 and the initial condition u(r,0) f(a) We found the solution to be of the form where (2n-1)n 1,2,3,. TL 20 Now consider the heat conduction problem with the boundary conditions u(0, t) 1,u(T, t)0, t>0 and the initial condition ur,0) 0. Find u(r,t). Hint: First you must find the steady state. 3. In class we discussed the heat conduction problem...

  • TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting...

    TRUE-FALSE     Basic synchronization principles and multithreading 1. Java user threads can implement both busy-waiting and no-busy-waiting policy. 2. Priority inversion avoids deadlocks. 3. Spinlock mutex can be used as an adaptive mutex. 4. Java RTE can be blocked for Input/Output operation. 5. Interrupted user thread, which executes a method in a monitor, must be rolled back to undo any changes it performed. 6. The synchronization primitive by disabling interrupts can be used by an application program. 7. Bounded-waiting requirement is...

  • In class we discussed several issues with self-driving cars. Indeed, many of you used this for...

    In class we discussed several issues with self-driving cars. Indeed, many of you used this for the ethical case study assignment. Self driving cars may be faced with choices where there is no single positive outcome (kili/injure the driver or the pedestrian or risk/gamble injuring a bystander). Attempt to create an algorithms in a few sentences (recall that an algorithm is simply a detailed sequence of steps, as unambiguous and concise as possible), one for each of the following scenarios:...

  • this question on the pic In class this week we discussed some of the principles of...

    this question on the pic In class this week we discussed some of the principles of point selection, including the role of the practitioner's intuition and the image that you hold in your mind for the treatment. What do you see as the most important principles to keep in mind when making acupuncture point selections? Besides learning the actions and indications of channels and points, what sorts of skills and knowledge do you hope to cultivate to help you with...

  • Please answer the following questions In your solution, use the vector notation we discussed in class...

    Please answer the following questions In your solution, use the vector notation we discussed in class and include a diagram of all of the forces with labelled axes A) Design your own homework problem. Consider an every day situation that involves at least three forces that are not all along the same line. Using reasonable values, calculate something interesting. B) Instead of using stairs and elevators, it would be much more fun to leave the T-building via a slide from...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT