added semaphores to network.c