[lkml]   [2004]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] Staircase scheduler v7.4
    Con Kolivas wrote:
    > On Sun, 27 Jun 2004, Con Kolivas wrote:
    >>Ok I found a problem which alost certainly is responsible in the
    >>conversion from nanoseconds to Hz and may if you're unlucky give a blank
    >>timeslice. Can you try this (against staircase7.4). I'm almost certain
    >>it's responsbile.
    > Hmm that will be the problem but that may not compile because of the darn
    > long long division thingy. I'll get a clean patch to you later on that
    > does the same thing, sorry.

    Here's a routine that I use for unsigned 64 bit divides. This is
    theoretically correct and (just to make sure :-)) thoroughly tested in a
    user space test program against a proper 64 bit divide. It can't be
    used to initialize static variables but that's OK because the compiler
    can do the 64 bit arithmetic itself to correctly initialize them.

    static inline unsigned long long sched_div_64(unsigned long long a,
    unsigned long long b)
    #if BITS_PER_LONG < 64
    * Assume that there's no 64 bit divide available
    if (a < b)
    return 0;
    * Scale down until b less than 32 bits so that we can do
    * a divide using do_div() (see div64.h).
    while (b > ULONG_MAX) { a >>= 1; b >>= 1; }

    (void)do_div(a, (unsigned long)b);

    return a;
    return a / b;

    PS If we knew the calling conventions for the library routines
    (__udivdi3, etc.) that the compiler tries to use to do 64 bit divides we
    could implement them in the kernel (where necessary) and 64 bit divide
    problems would become a thing of the past.
    Peter Williams

    "Learning, n. The kind of ignorance distinguishing the studious."
    -- Ambrose Bierce

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:04    [W:0.021 / U:3.264 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site