Question

In: Computer Science

The typical solution of the readers-writers problem works for the following assumptions: Only one writer at...

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.

Solutions

Expert Solution

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 :)


Related Solutions

The typical solution of the readers-writers problem works for the following assumptions: (a) Only one writer...
The typical solution of the readers-writers problem works for the following assumptions: (a) Only one writer at a time can access the buffer. Using semaphores, write psuedo code for the following two variations of the reader-writer problem. In each case, provide a short explanation of why there is no deadlock and no starvation in your new code. 1) exactly one writer and one reader exist Writer: Reader: 2) exactly two writers and two readers exist, where writers have priority Writer:...
The typical solution of the readers-writers problem works for the following assumptions: (a) Only one writer...
The typical solution of the readers-writers problem works for the following assumptions: (a) 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 Note: writers have priority In each case. Also, provide a short explanation (about 2 lines) of why there is no deadlock and no...
one-writer many-readers problem
Explain what is the problem with this implementation of the one-writer many-readers problem?
Adopt one (and only one) of the following assumptions and write a 150 word (or less)...
Adopt one (and only one) of the following assumptions and write a 150 word (or less) letter to the editor of a newspaper explaining why you either: 1. Oppose globalization 2. Are in favour of globalization (Choose only one position)
Suppose the price of one typical stock could only increase by 2 or decrease by 1...
Suppose the price of one typical stock could only increase by 2 or decrease by 1 in one day. From the historical data, we somehow know that this stock goes up with probability 0.7, goes down with probability 0.3. Suppose the initial price is 100. Suppose we want to study the price behavior for that stock for one week(5-weekdays). (Round your answer in 3 decimal Places) This question is just for setting up the model. what is the probability of...
For this project, following assumptions have been made:   The booking is only open for the next...
For this project, following assumptions have been made:   The booking is only open for the next seven days from the current date. Only two categories of the plane can be booked i.e. Economy and Business. The total number of tickets that can be booked in each category is 10 only. By ‘user’, we mean the person who is booking the ticket for the passenger(s). For example, an employee of Saudi Airline. Your project should include information about the following entities...
The basic assumptions is that the company has only one product. How can we use CVP...
The basic assumptions is that the company has only one product. How can we use CVP analysis for a multi-product company? Another basic assumption is that all costs can be classified as either fixed or variable. How can we adapt CVP analysis for situations that have step fixed or curve-linear variable costs?
Instructions: Solve the following problem. To receive credit, readers must be able to follow your logic...
Instructions: Solve the following problem. To receive credit, readers must be able to follow your logic and you must explain each step in detail. Please label each step, identify each equation and variable, and explain your answer. The management of a mutual fund plans to sell a basket of stocks in three months. The stocks are similar to the S&P 500. It seeks protection against a decrease in the price of the stocks. The current price of the S&P 500...
Which one of the following business strategies, used by Direct Writer insurers, involves an organization selling...
Which one of the following business strategies, used by Direct Writer insurers, involves an organization selling its product directly to the customer rather than through a wholesaler or other intermediary? Select one: a. Multi-divisional structure b. Differentiation c. Cost leadership d. Vertical integration
The following problem is an example of typical transactions that a not-for-profit college or university might...
The following problem is an example of typical transactions that a not-for-profit college or university might have.  Use the information in the FASB Accounting Standards Codification to help you answer the requirements of the problem. Beatty College, a not-for-profit college, engaged in the following transactions during its fiscal year ending June 30, 2015.          Requirements:  Prepare appropriate journal entries, indicating the types of funds (by restrictiveness) in which they would be recorded. Transactions:                1. In May 2015 Beatty College collected $100,000,000 in student...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT