Question: A multi-threaded program generates an incorrect answer some of the time raising the possibility of a race condition. Which of the following are steps that
A multi-threaded program generates an incorrect answer some of the time raising the possibility of a race condition. Which of the following are steps that can reduce or even eliminate race conditions in the program? Underline the R, E, or U below to indicate that the given approach can Reduce race conditions, Eliminate them, or is Useless when it comes to race conditions. Write a sentence to explain your answer.
R E U Separate the multithread program into multiple single-threaded programs, and run each thread in its own process. Share data between the programs via named pipes and read and write calls. No other changes to the program.
R E U Same as above, but share data between the programs via shared memory segments.
R E U Apply the one-writer rule. Here you modify the program so that each variable has only one writer, i.e. only one thread can write to a shared variable. Multiple threads can read from it.
R E U Ensure that each shared variable is protected by some lock.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
