Controlled sender and receiver with semaphores, added assert

Replaced some sleeps with semaphores
Replaced print statements with assert