I’m looking for any guidance on how to solve concurrency problem that will emerge when two processes are trying to access a shared resource (text file). The solution must use an algorithm and an array as a data structure to coordinate and arrange the execution of these two processes to solve concurrency.
I’m using C++ and POSIX API and I have read about several solutions to solve concurrency, but they use semaphores, locks and other methods but not arrays. Any guidance on how to do it using arrays?
I suspect you are being asked to produce an implementation of Peterson’s algorithm (or similar). This uses an integer and an array of booleans to implement a mutex, without requiring any platform support for synchronisation/atomic operations.