schedule: add wait and wake functions