Non-blocking IO demo in C++ using semaphores and shared memory