Re: [PATCH] O9int for interactivity

From: Guillaume Chazarain (gfc@altern.org)
Date: Sun Jul 27 2003 - 10:00:17 EST


27/07/03 03:57:19, Con Kolivas <kernel@kolivas.org> wrote:

>On Sun, 27 Jul 2003 07:20, Guillaume Chazarain wrote:
>> Hi Con,
>>
>> Strange your activate() function in O9. Isn't it?
>> It doesn't care that much about sleep_time.
>>
>> So here is a very simple trouble maker.
>
>Yes I know it's a way to make something fairly cpu intensive remain
>interactive. However since it sleeps long enough (2ms at 1000Hz is just
>enough), it doesn't bring the machine to a standstill, and is easily
>killable. I doubt it is worth working around this, but I'm open to your
>comments about variations on this theme that might be a problem.

The previous code was a mistake. (Calling clock() before sleeping is quite dumb...)
Here is another one. If you put the right value in MHZ, (maybe more, maybe less, I dunno),
I bet you won't get out without power cycling your box...

#include <unistd.h>

#define MHZ 450 /* Your CPU Mhz */
#define COUNT (MHZ * 1000)

#define PRIO_LEVELS 10

int main(void)
{
    int i;

    fork();
    fork();

    /* Climb all priority levels. */
    for (i = 0; i < PRIO_LEVELS; i++)
        usleep(1);

    for (;;) {
        usleep(1); /* get one point. */
        for (i = 0; i < COUNT; i++); /* lose one point. */
    }

    return 0;
}

Guillaume

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



This archive was generated by hypermail 2b29 : Thu Jul 31 2003 - 22:00:32 EST