I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures).
For performance reasons, I do not want to simply wrap the function calls in a mutex.
What I would like to do is to spawn, say 4 threads, and also load 4 copies of the same library into the process memory. Each thread then makes the function calls into its own copy of the library.
Unfortunately, dlopen does not allow me to load more one instance of any library.
Does anyone know of any method which will allow me to load the library more than once? (Other than making 4 copies of the .so file, each with a different name)
See Question&Answers more detail:os