This is test2.c in view mode; [Download] [Up]
/*
* mutex.c.2 Test of the global mutex.
*/
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include "utils.h"
#define THREADS 3
void
locker( void )
{
/*
* Recursively lock the global mutex.
*/
pthread_lock_global_np();
pthread_lock_global_np();
pthread_lock_global_np();
pthread_unlock_global_np();
pthread_unlock_global_np();
pthread_unlock_global_np();
pthread_exit( (void *) SUCCESS );
}
static pthread_t th[THREADS];
int
main( int argc, char *argv[] )
{
int i, status, exit_status;
for(i = 0; i < THREADS; i++ )
{
status = create_joinable( &th[i], (thread_proc_t) locker, NULL );
CHECK(status, "create_joinable()");
}
for(i = 0; i < THREADS; i++ )
{
status = pthread_join( th[i], (void **) &exit_status );
CHECK(status, "pthread_join()");
}
return( EXIT_SUCCESS );
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.