hw: implement priority-based scheduling (fix #945)