I am in the midst of developing two applications that communicate using a file. These applications are running on the same machine. To be clear, I have a writer.exe and a reader.exe executables.
The writer.exe constantly writes a random integer to a common file "some_file.bin" and closes the file. It repeats the same process again: opens the file, writes random int and closes it. This is done in a while loop.
The reader.exe is constantly reading the file "some_file.bin", printing the read integer to its console.
Both of these applications are written in C++ using the std::fstream class for file I/O.
So far, this is not working properly, because we have a race condition happening here.
I want some way to properly communicate between these two processes, using Win32 Events, so that the writer.exe process knows to wait until the reader.exe process has finished reading, and the reader.exe process knows to pause until the writer.exe process has finished writing.
I'm hoping to do this using the CreateEvent, WaitForSingleObject family of API calls present natively on the Windows platform.
Please feel free to tell me if this is possible between two processes?
So far, I have only found examples using the above APIs to signal threads of one main process... ?