Bill Allombert on Thu, 18 Aug 2005 17:06:41 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: PARI and POSIX threads |
On Mon, Aug 15, 2005 at 11:24:58PM +0200, Philippe Elbaz-Vincent wrote: > Hi, > > Is there a way to use PARI (i.e., in lib mode) inside a program > which uses posix threads (under Linux/2.6 with glibc 2.2.5 on x86_64) ? > (and of course knowing that there will be calls to PARI functions inside > threads). > As I understand the troubles come from the garbage collector as the > variables of > the PARI stack are globals and as soon that 2 threads run concurently the > PARI stack would be likely messed up [in fact I tested it and indeed it is > the case]. > > Is there a solution to this problem ? > [is it technically doable to run several instances of PARI inside the same > program ?] I am not sure the answer is known. What you can try is to mark avma, bot and top 'thread-local' using the '__thread' keyword (assuming this is supported) and use allocatemoremem() or switch_stack() to allocate a separate stack in each threads. To copy objects between threads, clone them. We would be very interested to know if that can be made to work. Cheers, Bill.