works ok in canneal still some problem of semaphores