OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
prime_search,
(pthread_addr_t)worker_num);
check(status,"19:Pthread_create bad status\n");
}
/*
* Set the predicate thread_hold to zero, and broadcast on the
* condition variable that the worker threads may proceed.
*/
status = pthread_mutex_lock (&cond_mutex);
check(status,"20:Mutex_lock bad status\n");
thread_hold = 0;
status = pthread_cond_broadcast (&cond_var);
check(status,"20.5:cond_broadcast bad status\n");
status = pthread_mutex_unlock (&cond_mutex);
check(status,"21:Mutex_unlock bad status\n");
/*
* Join each of the worker threads inorder to obtain their
* summation totals, and to ensure each has completed
* successfully.
*
* Mark thread storage free to be reclaimed upon termination by
* detaching it.
*/
for (worker_num = 0; worker_num < workers; worker_num++) {
status = pthread_join (
threads[worker_num],
&exit_value );
check(status,"23:Pthread_join bad status\n");
if (exit_value == worker_num) printf("thread terminated normally\n");
status = pthread_detach ( &threads[worker_num] );
check(status,"25:Pthread_detach bad status\n");
}
10 − 6 Tandem Computers Incorporated 124245