public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* O(1) scheduler ver H6 - more straightforward timeslice macros
@ 2002-01-12 19:16 James C. Owens
  2002-01-12 21:59 ` Matti Aarnio
  0 siblings, 1 reply; 7+ messages in thread
From: James C. Owens @ 2002-01-12 19:16 UTC (permalink / raw)
  To: mingo, linux-kernel

Ingo,

I like the new scheduler. It seems like the timeslice macros in sched.h 
could be more straighforward - i.e. instead of

#define PRIO_TO_TIMESLICE(p) \
((( (MAX_USER_PRIO-1-USER_PRIO(p))*(MAX_TIMESLICE-MIN_TIMESLICE) + \
MAX_USER_PRIO-1) / MAX_USER_PRIO) + MIN_TIMESLICE)

#define RT_PRIO_TO_TIMESLICE(p) \
((( (MAX_RT_PRIO-(p)-1)*(MAX_TIMESLICE-MIN_TIMESLICE) + \
MAX_RT_PRIO-1) / MAX_RT_PRIO) + MIN_TIMESLICE)

why not

#define PRIO_TO_TIMESLICE(p) \
(MAX_TIMESLICE - 
(USER_PRIO(p)/(MAX_USER_PRIO-1))*(MAX_TIMESLICE-MIN_TIMESLICE))

#define RT_PRIO_TO_TIMESLICE(p) \
(MAX_TIMESLICE - (p/(MAX_RT_PRIO-1))*(MAX_TIMESLICE-MIN_TIMESLICE))


The second way seems simpler to me, and really illustrates what you are 
doing in a more straightforward manner.

I also cleaned up some of the comments. The sched.h diff between the H6 
version of the scheduler applied to 2.4.18-pre3 and vanilla 2.4.18-pre3 
follows: (Note that I changed the min and max timeslices to 20 and 100 
for my own use.)


474c474

< * is for SCHED_OTHER tasks.
---
 > * is for SCHED_OTHER tasks. (Max Priority is 168.)
481c481
< * to static priority [ 24 ... 63 (MAX_PRIO-1) ]
---
 > * to static priority [ 128 ... 167 (MAX_PRIO-1) ]
483,484c483,484
< * User-nice value of -20 == static priority 24, and
< * user-nice value 19 == static priority 63. The lower
---
 > * User-nice value of -20 == static priority 128, and
 > * user-nice value 19 == static priority 167. The lower
486,488d485
< *
< * Note that while static priority cannot go below 24,
< * the priority of a process can go as low as 0.
495,496c492,493
< * Default timeslice is 90 msecs, maximum is 150 msecs.
< * Minimum timeslice is 30 msecs.
---
 > * Default timeslice is 60 msecs; maximum is 100 msecs.
 > * Minimum timeslice is 20 msecs.
498,499c495,496
< #define MIN_TIMESLICE	( 30 * HZ / 1000)
< #define MAX_TIMESLICE	(150 * HZ / 1000)
---
 > #define MIN_TIMESLICE	(20 * HZ / 1000)
 > #define MAX_TIMESLICE	(100 * HZ / 1000)
500a498,503
 > /*
 > * Scales priority values to user priority values.
 > * This means nice of -20 => p of 128 => user priority of 0.
 > * This means nice of +19 => p of 167 => user priority of 39.
 > * MAX_USER_PRIO is 40 which would be nice of +20.
 > */
505,506c508,512
< * PRIO_TO_TIMESLICE scales priority values [ 100 ... 139  ]
< * to initial time slice values [ MAX_TIMESLICE (150 msec) ... 2 ]
---
 > * PRIO_TO_TIMESLICE scales priority values [ 128 ... 167  ]
 > * to initial time slice values [ MAX_TIMESLICE ... MIN_TIMESLICE ]
 > *
 > * RT_PRIO_TO_TIMESLICE scales priority values [ 0 ... 127  ]
 > * to initial time slice values [ MAX_TIMESLICE ... MIN_TIMESLICE ]
508,509c514,515
< * The higher a process's priority, the bigger timeslices
< * it gets during one round of execution. But even the lowest
---
 > * The numerically lower a process's priority, the bigger timeslices
 > * it gets during one round of execution. But even the numerically highest
513,514c519
< ((( (MAX_USER_PRIO-1-USER_PRIO(p))*(MAX_TIMESLICE-MIN_TIMESLICE) + \
< MAX_USER_PRIO-1) / MAX_USER_PRIO) + MIN_TIMESLICE)
---
 > (MAX_TIMESLICE - 
(USER_PRIO(p)/(MAX_USER_PRIO-1))*(MAX_TIMESLICE-MIN_TIMESLICE))
517,518c522
< ((( (MAX_RT_PRIO-(p)-1)*(MAX_TIMESLICE-MIN_TIMESLICE) + \
< MAX_RT_PRIO-1) / MAX_RT_PRIO) + MIN_TIMESLICE)
---
 > (MAX_TIMESLICE - (p/(MAX_RT_PRIO-1))*(MAX_TIMESLICE-MIN_TIMESLICE))


To lkml - please cc me on any response, as I do not subscribe to the 
lkml - I read it via a news gateway.


Jim Owens
SuSE Linux 6.4 (kernel 2.4.18-pre3)
Tyan Tiger MP 2xAthlon MP 1600+
1.25 GB RAM


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-01-14 19:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-12 19:16 O(1) scheduler ver H6 - more straightforward timeslice macros James C. Owens
2002-01-12 21:59 ` Matti Aarnio
2002-01-12 22:18   ` James C. Owens
2002-01-13 18:08     ` Ingo Molnar
2002-01-13 18:42       ` James C. Owens
2002-01-13 20:55         ` Ingo Molnar
2002-01-14 18:59     ` george anzinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox