Lottery function

also changes to do_noquantum, do_stop_scheduling, and
do_start_scheduling