Ram writes a multi-threaded program, which produces an incorrect result some of the time, but always completes. He suspects a race condition. Which of the following are strategies that can reduce or eliminate race conditions in Ram’s program?
1
Ensuring that for each shared variable \(v\), it is protected by some lock \(l_v\).
2
Ensuring that all locks are acquired in the same order.
3
Separate a multi-threaded program into multiple single-threaded programs (each with its own address space) and share data between them via an inter-program communication primitive like pipes.
4
Both 1 and 3