449 Subj : Re: shared libraries reentrant? To : comp.programming.threads From : Ole Reinartz Date : Tue Sep 20 2005 11:42 am CFeil wrote: >Hi, > >how can I make a sharead library reentrant? > >I hvae some 3rd party device driver SW which I will make a library out of. >This library is planned to be used by to different threads. Is it possible >to have a shared library with ONE mutex which can be used by both threads, >Or is there any other way? > > 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. Thinking about it, is there some resource local to the shared lib (once per lib, not per process) you want to guard against multiple concurrent access? I'm currently not aware of a simple mechanism to achieve that. You may want to place your device driver in a process and then access the lib only through that process using some ipc- mechanism. Hope that helps Ole > > > . 0