8 #define numCyclesPerThread 500000
9 #define extraBytesInRecords 1000
14 char takeSpace[extraBytesInRecords];
19 char takeSpace[extraBytesInRecords];
26 char takeSpace[extraBytesInRecords];
30 void* workerMain( void* arg ) {
32 INTPTR i = (INTPTR)arg;
36 struct foo* foos = malloc( numCyclesPerThread*sizeof( struct foo ) );
38 for( j = 0; j < numCyclesPerThread; ++j ) {
39 br = calloc( 1, sizeof( struct bar ) );
40 bz = calloc( 1, sizeof( struct baz ) );
47 foos[j].z = foos[j].br->x + foos[j].bz->y;
64 pthread_t threads[numThreads];
69 pthread_attr_init( &attr );
70 pthread_attr_setdetachstate( &attr,
71 PTHREAD_CREATE_JOINABLE );
74 for( i = 0; i < numThreads; ++i ) {
76 pthread_create( &(threads[i]),
85 for( i = 0; i < numThreads; ++i ) {
88 pthread_join( threads[i],
91 for( j = 0; j < numCyclesPerThread; ++j ) {
99 printf( "\nTotal=%d\n", total );