Through an analysis of different approaches to the readers-writers problem, you have seen the key to solving starvation: since some threads will be starved if they are not given a high priority in accessing the shared resources, implementing fairness in the execution of all of the threads will prevent starvation from occurring. Fairness, in this case, does not require a program to forgo any order or priority that it has imposed on the different threads; but to implement fairness, a program needs to ensure that all threads are given sufficient opportunities to execute their instructions.
Keeping this idea in mind, we can potentially address the problem of starvation by implementing one (or a combination) of the following approaches:
- Increasing the priority of low-priority threads: As we did with the writer threads in the second approach and the reader threads...