Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
yield.c File Reference
#include <stdio.h>
#include "prthread.h"
#include "prinit.h"
#include "private/pprmisc.h"
#include <windows.h>

Go to the source code of this file.

Defines

#define THREADS   10

Functions

void threadmain (void *_id)
 main ()
 main()

Define Documentation

#define THREADS   10

Definition at line 49 of file yield.c.


Function Documentation

main ( void  )

main()

Definition at line 68 of file yield.c.

{
    int index;
    PRThread *a[THREADS];

    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 5);
    PR_STDIO_INIT();

    for (index=0; index<THREADS; index++) {
        a[index] = PR_CreateThread(PR_USER_THREAD,
                              threadmain,
                              (void *)index,
                              PR_PRIORITY_NORMAL,
                              index%2?PR_LOCAL_THREAD:PR_GLOBAL_THREAD,
                              PR_JOINABLE_THREAD,
                              0);
    }
    for(index=0; index<THREADS; index++)
        PR_JoinThread(a[index]);
    printf("main dying\n");
}

Here is the call graph for this function:

void threadmain ( void _id)

Definition at line 53 of file yield.c.

{
    int id = (int)_id;
    int index;

    printf("thread %d alive\n", id);
    for (index=0; index<10; index++) {
        printf("thread %d yielding\n", id);
        PR_Sleep(0);
        printf("thread %d awake\n", id);
    }
    printf("thread %d dead\n", id);

}

Here is the call graph for this function: