fixed stack sizes and a while loop problem for the semaphore