Wojtek Lerch
|
Re: PtAppAddCallback Issue
|
Wojtek Lerch
08/02/2011 10:07 AM
post87763
|
Re: PtAppAddCallback Issue
> Don't know if that could help, but I just had a case of PtAppCreatePulse doing
> a SIGSEGV, I traced it to PtInit being called in a thread that was terminated
> before the PtAppCreatedPulse was called, note that PtInit was being called
> again as the second thread that did the PtAppCreatePulse was called but that
> doesn't seems photon friendly.
Did you by any chance forget to PtEnter() before calling PtAppCreatePulse() in the second thread? This program works
for me:
#include <stdio.h>
#include <pthread.h>
#include <Pt.h>
static void *thread( void *arg ) {
if ( PtInit(NULL) ) {
perror( "PtInit" );
exit( 1 );
}
return NULL;
}
int main( int argc, char **argv ) {
int err;
pthread_t tid;
if ( ( err = pthread_create( &tid, NULL, thread, NULL ) ) != 0 ) {
fprintf( stderr, "pthread_create: %s\n", strerror(err) );
}
pthread_join( tid, NULL );
PtEnter(NULL);
printf( "Pulse is %d\n", PtAppCreatePulse( NULL, -1 ) );
return 0;
}
|
|
|