Debugging threads with HP Wilde Beest

ret_val = pthread_attr_setschedparam(&attr, &param);
check_error(ret_val, "attr_setschedparam() 2");
ret_val = pthread_create(&pth_id[1], &attr, thread2_func, NULL);
check_error(ret_val, "pthread_create() 2");
/* Destroy the thread attributes object */
ret_val = pthread_attr_destroy(&attr);
check_error(ret_val, "attr_destroy()");
/* wait for the threads to finish */
ret_val = pthread_join(pth_id[0], (void **)NULL);
check_error(ret_val, "pthread_join() 1");
ret_val = pthread_join(pth_id[1], (void **)NULL);
check_error(ret_val, "pthread_join() 2");
}
Such a situation does not necessarily result in a deadlock or application errors. However,
there might be instances of performance lag issues resulting from the mixed scheduling
policies.
The following command enables you to check this condition in a threaded application.
set thread-check mixed-sched-policy[on|off]
The following is a segment of the HP WDB output:
Starting program: /home/gdb/enh_thr_mixed_sched
In thread1_func()
[Switching to thread 3 (system thread 39724)]
warning: Attempt to synchronize threads 3 and 2 with different scheduling policies.
0x800003ffeffcc608 in __rtc_pthread_dummy+0 () from ../librtc64.sl
TIP: Consider changing the application such that the threads with the same scheduling
policy share the mutex.
Problem: Different threads non-concurrently wait on the same condition variable, but with different
associated mutexes.
Consider the following scenario:
Thread 1 with mutex A waiting on conditional variable CV1.
Thread 2 with mutex B waiting on conditional variable CV1.
Consider the following example enh_thr_cv_multiple_mxs.c
#include pthread.h
#include stdlib.h
#include errno.h
pthread_mutex_t job_lock1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t job_lock2 = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t job_cv = PTHREAD_COND_INITIALIZER;
extern void fatal_error(int err, char *f);
void
26