Subj : Re: Threads and different SpiderMonkey Runtimes To : Mads Bondo Dydensborg From : Mads Bondo Dydensborg Date : Mon Sep 26 2005 02:36 pm Mads Bondo Dydensborg skrev: > Hi > > I have a problem with using SpiderMonkey in my multithreaded C++ program. It seems my problem might be related to the nspr library. Iff I make sure that a threads has initialized the nspr library fully, before starting up all my other threads, I can run 3500 concurrent runtimes, each running their own contexts, objects and scripts without problems. (More than 3500 threads breaks my system because I only have 32 bit of virtual addressing, but that will not be a problem in practice). I have looked at the nspr code (pthread version, which is what I use), and it seems that the reason I did have problems, was because of races to the code in _PR_InitThreads. As long as I make sure that a single thread gets to call this code (possibly other pieces as well), before spawning all my other threads, things work out fine. Perhaps the lazy/implicit initialization of nspr (pthread version) needs to be wrapped in a call to pthread_once. My workaround is to run a single thread using a dummy javascript. It would be nice to not have to do that, though. Comments very welcome. Regards, Mads .