Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
suspend.c File Reference
#include "nspr.h"
#include "prpriv.h"
#include "prinrval.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Defines

#define SLEEP_TIME   4 /* secs */

Functions

void PR_CALLBACK Level_2_Thread (void *arg)
void PR_CALLBACK Level_1_Thread (void *arg)
static PRStatus PR_CALLBACK print_thread (PRThread *thread, int i, void *arg)
static void Level_0_Thread (PRThreadScope scope1, PRThreadScope scope2)
static void CreateThreadsUU (void)
static void CreateThreadsUK (void)
static void CreateThreadsKU (void)
static void CreateThreadsKK (void)
void main (int argc, char **argv)
 The Xalan testcases app.

Variables

PRMonitormon
PRInt32 count
PRInt32 alive

Define Documentation

#define SLEEP_TIME   4 /* secs */

Definition at line 70 of file suspend.c.


Function Documentation

static void CreateThreadsKK ( void  ) [static]

Definition at line 193 of file suspend.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void CreateThreadsKU ( void  ) [static]

Definition at line 188 of file suspend.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void CreateThreadsUK ( void  ) [static]

Definition at line 183 of file suspend.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void CreateThreadsUU ( void  ) [static]

Definition at line 178 of file suspend.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void Level_0_Thread ( PRThreadScope  scope1,
PRThreadScope  scope2 
) [static]

Definition at line 128 of file suspend.c.

{
    PRThread *thr;
    PRThread *me = PR_GetCurrentThread();
    int n;
    PRInt32 words;
    PRWord *registers;

    alive = 0;
    mon = PR_NewMonitor();

    alive = count;
    for (n=0; n<count; n++) {
        thr = PR_CreateThreadGCAble(PR_USER_THREAD,
            Level_1_Thread, 
            (void *)scope2, 
            PR_PRIORITY_NORMAL,
            scope1,
            PR_UNJOINABLE_THREAD,
            0);
        if (!thr) {
            printf("Could not create thread!\n");
            alive--;
        }
        printf("Level_0_Thread[0x%lx] created %15s thread 0x%lx\n",
            PR_GetCurrentThread(),
            (scope1 == PR_GLOBAL_THREAD) ?
            "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD",
            thr);

        PR_Sleep(0);
    }
    PR_SuspendAll();
    PR_EnumerateThreads(print_thread, NULL);
    registers = PR_GetGCRegisters(me, 1, (int *)&words);
    printf("My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
        registers[0],registers[1],registers[2],registers[3]);
    printf("My Stack Pointer = 0x%lx\n", PR_GetSP(me));
    PR_ResumeAll();

    /* Wait for all threads to exit */
    PR_EnterMonitor(mon);
    while (alive) {
        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);
    }

    PR_ExitMonitor(mon);
    PR_DestroyMonitor(mon);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 81 of file suspend.c.

{
    PRUint32 tmp = (PRUint32)arg;
    PRThreadScope scope = (PRThreadScope) tmp;
    PRThread *thr;

    thr = PR_CreateThreadGCAble(PR_USER_THREAD,
        Level_2_Thread,
        NULL,
        PR_PRIORITY_HIGH,
        scope,
        PR_JOINABLE_THREAD,
        0);

    if (!thr) {
        printf("Could not create thread!\n");
    } else {
        printf("Level_1_Thread[0x%lx] created %15s thread 0x%lx\n",
            PR_GetCurrentThread(),
            (scope == PR_GLOBAL_THREAD) ?
            "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD",
            thr);
        PR_JoinThread(thr);
    }
    PR_EnterMonitor(mon);
    alive--;
    PR_Notify(mon);
    PR_ExitMonitor(mon);
    printf("Thread[0x%lx] exiting\n",PR_GetCurrentThread());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file suspend.c.

{
    PR_Sleep(PR_MillisecondsToInterval(4 * 1000));
    printf("Level_2_Thread[0x%lx] exiting\n",PR_GetCurrentThread());
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 200 of file suspend.c.

{
    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    PR_STDIO_INIT();

#ifdef XP_MAC
    SetupMacPrintfLog("suspend.log");
#endif

    if (argc > 1) {
        count = atoi(argv[1]);
    } else {
        count = 5;
    }

    printf("\n\n%20s%30s\n\n"," ","Suspend_Resume Test");
    CreateThreadsUU();
    CreateThreadsUK();
    CreateThreadsKU();
    CreateThreadsKK();
    PR_SetConcurrency(2);

    printf("\n%20s%30s\n\n"," ","Added 2nd CPU\n");

    CreateThreadsUK();
    CreateThreadsKK();
    CreateThreadsUU();
    CreateThreadsKU();
    PR_Cleanup();
}

Here is the call graph for this function:

static PRStatus PR_CALLBACK print_thread ( PRThread thread,
int  i,
void arg 
) [static]

Definition at line 112 of file suspend.c.

{
    PRInt32 words;
    PRWord *registers;

    printf(
        "\nprint_thread[0x%lx]: %-20s - i = %ld\n",thread, 
        (PR_GLOBAL_THREAD == PR_GetThreadScope(thread)) ?
        "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD", i);
    registers = PR_GetGCRegisters(thread, 0, (int *)&words);
    printf("Regsters R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
        registers[0],registers[1],registers[2],registers[3]);
    printf("Stack Pointer = 0x%lx\n", PR_GetSP(thread));
    return PR_SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 68 of file suspend.c.

Definition at line 67 of file suspend.c.

Definition at line 66 of file suspend.c.