6 #include "config-test.h"
10 #define numCyclesPerThread 500000
11 #define extraBytesInRecords 1000
14 #ifdef CONFIG_POOLALLOC
15 __thread static MemPool* pool;
21 char takeSpace[extraBytesInRecords];
26 char takeSpace[extraBytesInRecords];
33 char takeSpace[extraBytesInRecords];
37 void* workerMain( void* arg ) {
39 INTPTR i = (INTPTR)arg;
43 struct foo* foos = malloc( numCyclesPerThread*sizeof( struct foo ) );
45 for( j = 0; j < numCyclesPerThread; ++j ) {
46 br = poolalloc( barPool );
47 bz = poolalloc( bazPool );
54 foos[j].z = foos[j].br->x + foos[j].bz->y;
56 poolfree( barPool, foos[j].br );
57 poolfree( bazPool, foos[j].bz );
71 pthread_t threads[numThreads];
77 #ifdef CONFIG_POOLALLOC
78 pool = poolcreate( sizeof( struct bar ) );
82 pthread_attr_init( &attr );
83 pthread_attr_setdetachstate( &attr,
84 PTHREAD_CREATE_JOINABLE );
87 for( i = 0; i < numThreads; ++i ) {
89 pthread_create( &(threads[i]),
98 for( i = 0; i < numThreads; ++i ) {
101 pthread_join( threads[i],
104 for( j = 0; j < numCyclesPerThread; ++j ) {
112 printf( "\nTotal=%d\n", total );