Debugging threads with HP Wilde Beest

producer_thread(pthread_mutex_t* job_lock)
{
int ret_val;
/* Acquire the associated mutex lock */
if ((ret_val = pthread_mutex_lock(job_lock)) != 0)
fatal_error(ret_val, "p mtx_lock failed");
/* Signal the condvar to wakeup one thread */
if ((ret_val = pthread_cond_signal(&job_cv)) != 0)
fatal_error(ret_val, "cond_signal failed");
/* Release the associated mutex */
if ((ret_val = pthread_mutex_unlock(job_lock)) != 0)
fatal_error(ret_val, "mtx_unlock failed");
}
void
consumer_thread(pthread_mutex_t* job_lock)
{
int ret_val;
/* Acquire the condvar's associated mutex lock */
if ((ret_val = pthread_mutex_lock(job_lock)) != 0)
fatal_error(ret_val, "c mtx_lock failed");
pthread_cond_wait(&job_cv, job_lock);
/* Release the associated mutex */
if ((ret_val = pthread_mutex_unlock(job_lock)) != 0)
fatal_error(ret_val, "mtx_unlock failed");
}
#define check_error(return_val, msg) { \
if (return_val != 0) \
fatal_error(return_val, msg); \
}
int main(int argc, char* argv[])
{
pthread_t tid1, tid2, tid3, tid4;
pthread_mutex_t *l1, *l2;
int ret_val;
if (argc == 1) {
fprintf(stderr, "error: no arguments\n");
exit (1);
}
else if (strcmp(argv[1], "bad") == 0) {
Modes of Thread debugging in HP WDB 27