Debugging threads with HP Wilde Beest

/* Print error information, exit with -1 status. */
void
fatal_error(int err_num, char *function)
{
char *err_string;
err_string = strerror(err_num);
fprintf(stderr, "%s error: %s\n", function, err_string);
exit(-1);
}
#define check_error(return_val, msg) { \
if (return_val != 0) \
fatal_error(return_val, msg); \
}
main()
{
pthread_mutexattr_t mtx_attr;
pthread_t tid1;
extern void start_routine(int num);
int ret_val;
alarm (20);
/* Initialize the mutex attributes */
ret_val = pthread_mutexattr_init(&mtx_attr);
check_error(ret_val, "mutexattr_init failed");
/* Set the type attribute to recursive */
ret_val = pthread_mutexattr_settype(&mtx_attr,
PTHREAD_MUTEX_RECURSIVE);
check_error(ret_val, "mutexattr_settype failed");
/* Initialize the recursive mutex */
ret_val = pthread_mutex_init(&r_mtx, &mtx_attr);
check_error(ret_val, "mutex_init failed");
/* Set the type attribute to normal */
ret_val = pthread_mutexattr_settype(&mtx_attr,
PTHREAD_MUTEX_NORMAL);
check_error(ret_val, "mutexattr_settype failed");
/* Initialize the normal mutex */
ret_val = pthread_mutex_init(&n_mtx, &mtx_attr);
check_error(ret_val, "mutex_init failed");
/* Destroy the attributes object */
ret_val = pthread_mutexattr_destroy(&mtx_attr);
check_error(ret_val, "mutexattr_destroy failed");
20