Messages in this thread Patch in this message | | | Date | Mon, 8 Feb 1999 23:42:59 +0100 | From | Peter Steiner <> | Subject | Re: Real Time scheduler? |
| |
To: linux-kernel@vger.rutgers.edu Subject: Re: Real Time scheduler? In-Reply-To: <Pine.LNX.4.03.9902081557070.28564-100000@mirkwood.dummy.home>
>I am (or rather, will be once 2.2 stabilizes) working >on the exact opposite: SCHED_IDLE processes which only >run when the system's got nothing else to do.
I already have something like that. It's a modification of how niceness values are interpreted. It uses a range of 11 niceness values to get the processor, e.g. when there's a process running at nice=0 then no proces with nice=11 or higher will get the cpu. On the other hand, if there's a process running at nice=-11 (eg. timidity or mikmod) then no 'normal' process will get the cpu. Processes started just with nice will still get a little bit of the cpu as usual (that's why the range is 11 and not 10).
I used it on 2.0.36. This is a version for 2.2.
Peter
--- sched.c.original Mon Feb 8 19:44:50 1999 +++ sched.c Mon Feb 8 23:33:55 1999 @@ -171,7 +171,8 @@ static inline void reschedule_idle(struct task_struct * p) { - if (p->policy != SCHED_OTHER || p->counter > current->counter + 3) { + if (p->policy != SCHED_OTHER || + p->counter+(p->priority<<2)>=current->counter+(current->priority<<2)) { current->need_resched = 1; return; } @@ -360,9 +361,9 @@ * Don't do any other calculations if the time slice is * over.. */ - weight = p->counter; - if (weight) { - + weight = p->counter+(p->priority<<2); + if (p->counter) { + #ifdef __SMP__ /* Give a largish advantage to the same processor... */ /* (this is equivalent to penalizing other processors) */ @@ -373,7 +374,7 @@ /* .. and a slight advantage to the current thread */ if (p->mm == prev->mm) weight += 1; - weight += p->priority; + weight += 1; /* nice compatibility */ } return weight; @@ -716,11 +717,12 @@ } /* Do we need to re-calculate counters? */ - if (!c) { + if (c <= (next->priority << 2)) { struct task_struct *p; read_lock(&tasklist_lock); for_each_task(p) - p->counter = (p->counter >> 1) + p->priority; + p->counter = (p->counter + 41) >> 1; + read_unlock(&tasklist_lock); } } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |