assets/joinall-1.c
void *PingPongThread(void *arg)
{
	struct thread_arg *ta = (struct thread_arg *)arg;
	int i;

	for(i=0; i < ta->count; i++) {
		P_kt_sem(ta->next);
			*(ta->shared_counter) =
				*(ta->shared_counter) + 1.0;
		if(ta->verbose == 1) {
			printf("thread %d: incremented shared counter to %f\n",
				ta->id,
				*(ta->shared_counter));
		}
		V_kt_sem(ta->next);
	}

	*(ta->finished) = *(ta->finished) + 1;

	kt_exit();
	return(NULL);
}
/*
 * bumps the shared counter by 1 each time it is enabled
 */
bumps the shared counter by 1 each time it is enabled
bumps the shared counter by 1 each time it is enabled
void *PingPongThread(void *arg)
{
	struct thread_arg *ta = (struct thread_arg *)arg;
	int i;
	for(i=0; i < ta->count; i++) {
		P_kt_sem(ta->next);
			*(ta->shared_counter) =
				*(ta->shared_counter) + 1.0;
		if(ta->verbose == 1) {
			printf("thread %d: incremented shared counter to %f\n",
				ta->id,
				*(ta->shared_counter));
		}
		V_kt_sem(ta->next);
	}
	*(ta->finished) = *(ta->finished) + 1;
	kt_exit();
	return(NULL);
}
void * PingPongThread ( void * arg ) { struct thread_arg * ta = ( struct thread_arg * ) arg ; int i ; for ( i = 0 ; i < ta -> count ; i ++ ) { P_kt_sem ( ta -> next ) ; * ( ta -> shared_counter ) = * ( ta -> shared_counter ) + 1.0 ; if ( ta -> verbose == 1 ) { printf ( " \n " , ta -> id , * ( ta -> shared_counter ) ) ; } V_kt_sem ( ta -> next ) ; } * ( ta -> finished ) = * ( ta -> finished ) + 1 ; kt_exit ( ) ; return ( NULL ) ; }
bumps the shared counter by 1 each time it is enabled
bumps the shared counter by 1 each time it is enabled