Code: Show/Hide if (action == MM_LOAD) { pthread_create(&thd, NULL, thread_check, NULL); mm->RegCallback(CB_MAINLOOP, increment, ALLARENAS); return MM_OK; } else if (action == MM_UNLOAD) { mm->UnregCallback(CB_MAINLOOP, increment, ALLARENAS); pthread_cancel(thd); pthread_join(thd, NULL); return MM_OK; } |
Code: Show/Hide local void * thread_check(void *dummy)
{ /* wait a minute initially */ fullsleep(60 * 1000); for (;;) { int seen = counter; /* and then 10 seconds each iteration */ fullsleep(10 * 1000); if (counter == seen) { fprintf(stderr, "E <deadlock> deadlock detected, aborting\n"); abort(); } } } local void increment(void) { counter++; } |