Add calc_priority() and check_yield()