#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
struct thread_data
{
uint64_t sequence;
pthread_t tid;
uint64_t lid;
};
static pthread_key_t tpd;
get_time( void )
{
struct thread_data* data = pthread_getspecific( tpd );
return data->sequence++;
}
pre_flush( void* userData,
void* callerData,
bool final )
{
}
post_flush( void* userData,
{
return get_time();
}
{
.otf2_post_flush = post_flush
};
void*
event_writer( void* arg )
{
struct thread_data* data = arg;
pthread_setspecific( tpd, data );
data->lid );
NULL,
get_time(),
0 );
NULL,
get_time(),
0 );
return NULL;
}
int
main( int argc,
char** argv )
{
int number_of_threads = 1;
if ( argc > 1 )
{
number_of_threads = atoi( argv[ 1 ] );
}
pthread_key_create( &tpd, NULL );
"ArchiveName",
1024 * 1024 ,
4 * 1024 * 1024 ,
struct thread_data* threads = calloc( number_of_threads, sizeof( *threads ) );
for ( int i = 0; i < number_of_threads; i++ )
{
threads[ i ].archive = archive;
threads[ i ].lid = i;
pthread_create( &threads[ i ].tid, NULL, event_writer, &threads[ i ] );
}
for ( int i = 0; i < number_of_threads; i++ )
{
pthread_join( threads[ i ].tid, NULL );
}
for ( int thread = 0; thread < number_of_threads; thread++ )
{
thread );
}
1 ,
0 ,
2 );
0 ,
3 ,
4 ,
5 ,
0 ,
0 ,
0 );
0 ,
6 ,
7 ,
0 ,
1 ,
0 );
for ( int i = 0; i < number_of_threads; i++ )
{
if ( i > 0 )
{
name = 7 + i;
char name_buf[ 32 ];
sprintf( name_buf, "Pthread %d", i );
}
i ,
name,
2 ,
0 );
}
pthread_key_delete( tpd );
return EXIT_SUCCESS;
}