aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-08-25 04:43:14 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-08-25 04:43:14 -0400
commit5809f5408f551971a5950e8f046eb6b73db4842f (patch)
tree81b269b1c2fdbf67b9dfa414c84eca9e176e2c6d
parent34770c2be5a07a7d83a0cb63ca4f2dbbd2c83fcb (diff)
PFAIR: don't crash on weight 1.0 tasks
Avoid division by zero.
-rwxr-xr-xlitmus/sched_pfair.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/litmus/sched_pfair.c b/litmus/sched_pfair.c
index beb303c352..ad082a3a6f 100755
--- a/litmus/sched_pfair.c
+++ b/litmus/sched_pfair.c
@@ -684,7 +684,8 @@ static void init_subtask(struct subtask* sub, unsigned long i,
684 if (2 * quanta >= period) { 684 if (2 * quanta >= period) {
685 /* heavy */ 685 /* heavy */
686 tmp = (sub->deadline - (i + 1)) * period; 686 tmp = (sub->deadline - (i + 1)) * period;
687 if (do_div(tmp, (period - quanta))) /* ceil */ 687 if (period > quanta &&
688 do_div(tmp, (period - quanta))) /* ceil */
688 tmp++; 689 tmp++;
689 sub->group_deadline = (quanta_t) tmp; 690 sub->group_deadline = (quanta_t) tmp;
690 } else 691 } else
@@ -734,6 +735,15 @@ static long pfair_admit_task(struct task_struct* t)
734 return -EINVAL; 735 return -EINVAL;
735 } 736 }
736 737
738 if (quanta == period) {
739 /* special case: task has weight 1.0 */
740 printk(KERN_INFO
741 "Admitting weight 1.0 task. (%s/%d, %llu, %llu).\n",
742 t->comm, t->pid, quanta, period);
743 quanta = 1;
744 period = 1;
745 }
746
737 param = kmalloc(sizeof(struct pfair_param) + 747 param = kmalloc(sizeof(struct pfair_param) +
738 quanta * sizeof(struct subtask), GFP_ATOMIC); 748 quanta * sizeof(struct subtask), GFP_ATOMIC);
739 749