FreeBSD/contrib/ntp/ntpd/ntpd.c
/* pre-heat threading: create a thread and cancel it, just to exercise
 * thread cancellation.
 */
pre-heat threading: create a thread and cancel it, just to exercise
thread cancellation.
pre - heat threading : create a thread and cancel it just to exercise thread cancellation .
static void
my_pthread_warmup(void)
{
	pthread_t 	thread;
	pthread_attr_t	thr_attr;
	int       	rc;
	pthread_attr_init(&thr_attr);
#if defined(HAVE_PTHREAD_ATTR_GETSTACKSIZE) && \
    defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && \
    defined(PTHREAD_STACK_MIN)
	rc = pthread_attr_setstacksize(&thr_attr, PTHREAD_STACK_MIN);
	if (0 != rc)
		msyslog(LOG_ERR,
			"my_pthread_warmup: pthread_attr_setstacksize() -> %s",
			strerror(rc));
#endif
	rc = pthread_create(
		&thread, &thr_attr, my_pthread_warmup_worker, NULL);
	pthread_attr_destroy(&thr_attr);
	if (0 != rc) {
		msyslog(LOG_ERR,
			"my_pthread_warmup: pthread_create() -> %s",
			strerror(rc));
	} else {
		pthread_cancel(thread);
		pthread_join(thread, NULL);
	}
}
static void my_pthread_warmup ( void ) { pthread_t thread ; pthread_attr_t thr_attr ; int rc ; pthread_attr_init ( & thr_attr ) ; #if defined ( HAVE_PTHREAD_ATTR_GETSTACKSIZE ) && defined ( HAVE_PTHREAD_ATTR_SETSTACKSIZE ) && defined ( PTHREAD_STACK_MIN ) rc = pthread_attr_setstacksize ( & thr_attr , PTHREAD_STACK_MIN ) ; if ( 0 != rc ) msyslog ( LOG_ERR , " " , strerror ( rc ) ) ; #endif rc = pthread_create ( & thread , & thr_attr , my_pthread_warmup_worker , NULL ) ; pthread_attr_destroy ( & thr_attr ) ; if ( 0 != rc ) { msyslog ( LOG_ERR , " " , strerror ( rc ) ) ; } else { pthread_cancel ( thread ) ; pthread_join ( thread , NULL ) ; } }
pre-heat threading: create a thread and cancel it, just to exercise
 thread cancellation.
pre - heat threading : create a thread and cancel it just to exercise thread cancellation .