Listing 1: victimCompare
/* victimCompare(v1, v2)
*
* returns:
* -1 if v1 is *more* eligible to be kicked off than v2
* 0 if v1 and v2 are equally eligible to be kicked off
* 1 if v2 is *more* eligible to be kicked off than v1
*/
int
victimCompare(v1, v2) {
if (PRIORITY(v1) == PRIORITY(v2)) {
if (v1->timeLeft == v2->timeLeft)
return 0;
else if (v1->timeLeft < v2->timeLeft)
return -1;
else
return 1;
} else if (PRIORITY(v1) < PRIORITY(v2))
return -1;
else
return 1;
}
|