Hi Adam,
try to use TThread class. It is based on pthread too but there are some additional
tricks for working inside ROOT. If it will not work too, then I and other
TThread experts can help you.
Victor
Adam Jon DeGrush wrote:
>
> Hello Rooters,
>
> I am trying to launch a thread (using posix thread) that handles
> asynchronous events from a root gui. I can avoid a segmentation violation
> during the thread's initialization only if I put it to sleep immediately
> after I call the thread. Something like this
>
> if (parm1 == 6){
> pthread_create(&thread2, NULL,
> caMonitorThread, (void *)NULL);
> nanosleep(&tenseconds, NULL);
> }
>
> but of course when an event gets processed sometime later I will get a
> segmentation violation. I guess I don't understand what memory my
> TApplication is trying to access while my gui is sitting idly that my
> thread is also trying to access.
>
> I should also note that the thread works if run from main like
>
> int main(int argc, char **argv)
> {
> pthread_mutex_init(&mutex, NULL);
> while(1){}
> return 0;
> }
>
> but fails if
>
> int main(int argc, char **argv)
> {
> pthread_mutex_init(&mutex, NULL);
> pthread_create(&thread2, NULL,
> caMonitorThread, (void *)NULL);
> TApplication theApp("App", &argc, argv);
> theApp.Run();
> return 0;
> }
>
> Is there something obvious that I should be doing?
>
> Thanks a lot
> Adam DeGrush
--
Victor M. Perevoztchikov perev@bnl.gov perev@vxcern.cern.ch
Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000
tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:39 MET