enum ProcessStatus {
ready,
waiting_on_key_stroke,
waiting_on_printer,
...
};
struct ProcessRecord {
ProcessStatus status;
int priority; // smaller is better
void * restartPoint;
...
};
int compare(ProcessRecord a, ProcessRecord b) {
if (a.status == ready and b.status != ready
or
a.status == b.status and a.priority < b.priority)
return -1; // a has "higher" priority
if (a.status == b.status and a.priority == b.priority)
return 0; // equal priorities
else
return 1; // b has "higher" priority
}