Index: linux-2.6.8.1-ck8/include/linux/sched.h =================================================================== --- linux-2.6.8.1-ck8.orig/include/linux/sched.h 2004-09-17 00:29:11.220665863 +1000 +++ linux-2.6.8.1-ck8/include/linux/sched.h 2004-09-17 00:29:11.913553884 +1000 @@ -127,9 +127,10 @@ extern unsigned long nr_iowait(void); #define SCHED_FIFO 1 #define SCHED_RR 2 #define SCHED_BATCH 3 +#define SCHED_ISO 4 #define SCHED_MIN 0 -#define SCHED_MAX 3 +#define SCHED_MAX 4 #define SCHED_RANGE(policy) ((policy) >= SCHED_MIN && \ (policy) <= SCHED_MAX) @@ -312,6 +313,7 @@ struct signal_struct { #define rt_task(p) ((p)->prio < MAX_RT_PRIO) #define batch_task(p) ((p)->policy == SCHED_BATCH) +#define iso_task(p) ((p)->policy == SCHED_ISO) /* * Some day this will be a full-fledged user tracking system.. Index: linux-2.6.8.1-ck8/kernel/sched.c =================================================================== --- linux-2.6.8.1-ck8.orig/kernel/sched.c 2004-09-17 00:29:11.223665378 +1000 +++ linux-2.6.8.1-ck8/kernel/sched.c 2004-09-17 00:29:22.523839170 +1000 @@ -250,6 +250,8 @@ static unsigned int burst(task_t *p) { if (likely(!rt_task(p))) { unsigned int task_user_prio = TASK_USER_PRIO(p); + if (iso_task(p)) + task_user_prio /= 2; return 39 - task_user_prio; } else return p->burst; @@ -288,6 +290,18 @@ static unsigned long slice(task_t *p) */ int sched_interactive = 1; +static unsigned long rr_interval(task_t * p) +{ + unsigned long rr_interval = RR_INTERVAL(); + if (batch_task(p)) + rr_interval *= 10; + else if (iso_task(p)) + rr_interval /= 2; + if (!rr_interval) + rr_interval = 1; + return rr_interval; +} + /* * effective_prio - dynamic priority dependent on burst. * The priority normally decreases by one each RR_INTERVAL. @@ -315,17 +329,18 @@ static int effective_prio(task_t *p) best_burst = burst(p); full_slice = slice(p); + rr = rr_interval(p); used_slice = full_slice - p->slice; if (p->burst > best_burst) p->burst = best_burst; - first_slice = RR_INTERVAL(); - if (sched_interactive && !sched_compute && p->mm) + first_slice = rr; + if (sched_interactive && !sched_compute && p->mm && !iso_task(p)) first_slice *= (p->burst + 1); prio = MAX_PRIO - 2 - best_burst; if (used_slice < first_slice) return prio; - prio += 1 + (used_slice - first_slice) / RR_INTERVAL(); + prio += 1 + (used_slice - first_slice) / rr; if (prio > MAX_PRIO - 2) prio = MAX_PRIO - 2; return prio; @@ -340,7 +355,7 @@ static void recalc_task_prio(task_t *p, { unsigned long long _sleep_time = now - p->timestamp; unsigned long sleep_time = NS_TO_US(_sleep_time); - unsigned long rr = RR_INTERVAL(); + unsigned long rr = rr_interval(p); unsigned int best_burst = burst(p); unsigned long minrun = rr * (p->burst + 1) / (best_burst + 1) ? : 1; @@ -392,7 +407,7 @@ static void activate_task(task_t *p, run } #endif p->slice = slice(p); - p->time_slice = RR_INTERVAL(); + p->time_slice = rr_interval(p); recalc_task_prio(p, now); p->prio = effective_prio(p); p->flags &= ~PF_UISLEEP; @@ -1765,7 +1780,7 @@ static void time_slice_expired(task_t *p set_tsk_need_resched(p); dequeue_task(p, rq); p->prio = effective_prio(p); - p->time_slice = RR_INTERVAL(); + p->time_slice = rr_interval(p); enqueue_task(p, rq); } @@ -2559,7 +2574,11 @@ static int setscheduler(pid_t pid, int p retval = -EPERM; if (SCHED_RT(policy) && !capable(CAP_SYS_NICE)) - goto out_unlock; + /* + * If the caller requested an RT policy without having the + * necessary rights, we downgrade the policy to SCHED_ISO. + */ + policy = SCHED_ISO; if ((current->euid != p->euid) && (current->euid != p->uid) && !capable(CAP_SYS_NICE)) goto out_unlock; @@ -2805,7 +2824,7 @@ asmlinkage long sys_sched_yield(void) dequeue_task(current, rq); current->slice = slice(current); - current->time_slice = RR_INTERVAL(); + current->time_slice = rr_interval(current); if (likely(!rt_task(current) && !batch_task(current))) { current->flags |= PF_YIELDED; current->prio = MAX_PRIO - 2; @@ -2894,6 +2913,7 @@ asmlinkage long sys_sched_get_priority_m break; case SCHED_NORMAL: case SCHED_BATCH: + case SCHED_ISO: ret = 0; break; } @@ -2918,6 +2938,7 @@ asmlinkage long sys_sched_get_priority_m break; case SCHED_NORMAL: case SCHED_BATCH: + case SCHED_ISO: ret = 0; } return ret;