test/testlock.c
changeset 6977 b73d51026c68
parent 5969 3a041d215edc
child 7191 75360622e65f
equal deleted inserted replaced
6976:177d1dc3dba6 6977:b73d51026c68
    67 {
    67 {
    68     if (SDL_ThreadID() == mainthread)
    68     if (SDL_ThreadID() == mainthread)
    69         signal(SIGTERM, closemutex);
    69         signal(SIGTERM, closemutex);
    70     while (!doterminate) {
    70     while (!doterminate) {
    71         printf("Process %lu ready to work\n", SDL_ThreadID());
    71         printf("Process %lu ready to work\n", SDL_ThreadID());
    72         if (SDL_mutexP(mutex) < 0) {
    72         if (SDL_LockMutex(mutex) < 0) {
    73             fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
    73             fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
    74             exit(1);
    74             exit(1);
    75         }
    75         }
    76         printf("Process %lu, working!\n", SDL_ThreadID());
    76         printf("Process %lu, working!\n", SDL_ThreadID());
    77         SDL_Delay(1 * 1000);
    77         SDL_Delay(1 * 1000);
    78         printf("Process %lu, done!\n", SDL_ThreadID());
    78         printf("Process %lu, done!\n", SDL_ThreadID());
    79         if (SDL_mutexV(mutex) < 0) {
    79         if (SDL_UnlockMutex(mutex) < 0) {
    80             fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
    80             fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
    81             exit(1);
    81             exit(1);
    82         }
    82         }
    83         /* If this sleep isn't done, then threads may starve */
    83         /* If this sleep isn't done, then threads may starve */
    84         SDL_Delay(10);
    84         SDL_Delay(10);