switched to writing to file in semaphores rather than global variables, need to use shared memory