In: Computer Science
The typical solution of the readers-writers problem works for the following assumptions: Only one writer at a time can access the buffer.
Write two separate solutions (pseudo code) for the reader and the writer processes in the cases in which
1) exactly one writer and one reader exist
2) exactly two writers and two readers exist, where writers have priority
In each case, provide a short explanation of why there is no deadlock and no starvation in your new code.
Two separate pseudo code for the reader and the writer processes in the cases in which
1) exactly one writer and one reader exist.
2) exactly two writers and two readers exist.
Condition: - writers have priority In each case
pseudo code for Writer process
i) Writer asks the entry to critical section.
ii) If it is true or accepted, it goes into critical section and starting the operation.
ii) If it is false, it will wait until it is accepted.
pseudo code for reader process
i) Reader ask the entry to critical section. than in this case also 2 case are possible
If True: it will the count of number of readers available inside the section. If reader is the 1st one in section than it locks the setion to ensure no new entry of readers and also checks entry of writers if reader is already there.
it will also checks if other reader is allowed to enter while others are there.
it will also checks if other writer is allowed to enter while others are there.
After opration of reading and writing, both will quit the critical section.
ii) If not False, it will wait until it is accepted.
There is no deadlock and no starvation in my new because no process is being blocked by anyone it will work flawlessly without distraction with each others processes.
----------------------------------------
Please give me a UPVOTE. Thank you :)