Reimplemented timer_sleep to not use busy waiting