Subj : Re: shared libraries reentrant? To : comp.programming.threads From : Chris Friesen Date : Tue Sep 20 2005 10:08 am Ole Reinartz wrote: > Easy: create a mutex, lock it whenever you enter the lib, unlock it > whenever you're done with it. You can perfectly well place the mutex in > your shared lib, AFAIK it will be then created per process that uses the > lib. This is not sufficient. You also need to make sure that any syscalls you use are reentrant. Often it works better to not store any global data in your library. If you go this way you give an opaque handle to the application containing all the state the library needs. On any library call, the application passes in the handle as one of the arguments. That way you don't need a mutex within the library itself. Chris .