|
On Apr 3, 2007, at 2:35 PM, Asko Kauppi wrote:
I've poked around some more, and downloaded the source code for the Mac OS X dynamic linker in OS X 10.4.8. I've found the following: - turning off the PRIVATE flag does not seem to resolve anything, you still get multiple copies of your variables and code. Not a good idea if lots of OS threads load the same library module, especially if the code is not position-independent. Turning off the 'PRIVATE' flag just puts the global symbols of one of the loaded modules into the global symbol table. - the dlopen interface on OS X 10.4 is thread safe and uses reference counting to avoid loading a dynamic library twice. - the 'dlcompat' implementation of dlopen on OS X 10.3 does the same thing, albeit a little bit less efficiently. There are two ways to go: - rewrite the Mac OS X dynamic loading routines in the Lua sources to use reference counting to keep track of multiple uses of the same library. Make sure a read/write lock is used to handle multiple Lua instances trying to load the same module at the same time. This should not be frightfully hard, but it adds more OS dependent code to Lua. - switch to 'dlopen' and ignore Mac OS X 10.2.8 and earlier. I prefer the last option, it's simple, and only requires a small change to the default Makefile. The Mac OS X specific code can be left in for people requiring support for Mac OS X <= 10.2.8. They could install the 'dlcompat' library if they need to run multiple OS threads. Gé -- Gé Weijers |