[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: O(1) scheduler ver H6 - more straightforward timeslice macros


> -----Original Message-----
> From: Matti Aarnio [mailto:matti.aarnio _at_ zmailer.org]
> Sent: Saturday, January 12, 2002 5:00 PM
> To: James C. Owens
> Cc: mingo _at_ elte.hu; linux-kernel _at_ vger.kernel.org
> Subject: Re: O(1) scheduler ver H6 - more straightforward timeslice
> macros
>
>
> On Sat, Jan 12, 2002 at 02:16:08PM -0500, James C. Owens wrote:
> > Ingo,
> >
> > I like the new scheduler. It seems like the timeslice
> macros in sched.h
> > could be more straighforward - i.e. instead of
>
>    (I quote too much, but to illustriate the point...)
>
> > #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.
>
>    Except that the math is INTEGER, not floating-point,
>    which means that this way you loose precission.
>
>    You HAVE TO do multiplications first, only then (finally)
> the division.
>
>    Depending the value-spaces, small-enough value-spaces might be
>    turnable into table mappings.  However that has lots of
> dependencies
>    in hardware architecture, e.g. memory access speeds, cache
> pollution,
>    speed of multiply/divide operations, etc.
>
>    If dividers/multipliers are constants, and powers of two, the math
>    can happen with constant shifts, which are fast at all systems.
>    If not, things get rather complicated.   (And thus a careless -1,
>    or lack of one, may be costly.)
>
[snip]
> /Matti Aarnio
>

Point well made. How about

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

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

If people agree with this, I'll submit a new diff (with the right options).

Jim Owens


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo _at_ vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


この情報があなたの探していたものかどうか選択してください。
yes/まさにこれだ!   no/違うなぁ   part/一部見つかった   try/これで試してみる

あなたが探していた情報はどのようなことか、ご自由に記入下さい。特に「まさにこれだ!」と言う場合は記入をお願いします。
例:「複数のマシンからCATV経由でipmasqueradeを利用してWebを参照したい場合の設定について」
Follow-Ups: References: