Adding semaphore.c and other changes