Home > Archive > Unix Programming > February 2005 > dlopen and semaphores
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
dlopen and semaphores
|
|
| Orioniz@gmail.com 2005-02-14, 4:01 pm |
| Hi,
I have a program with several threads. Lets call then A and B.
The B has a queue of messages it has to deal with. A then puts a
message in the B's queue (with a pointer to a sem_t object) and calls
sem_wait on the sem_t object. A then waits for B to handle the msg, and
B then calls sem_post, so that A can continue.
This all works fine when I don't use dynamic libraries, but when I load
A using a pointer to a function from a dynamic library, the threads
start fine, the msg from A gets send and B calls sem_post (returns 0)
as expected, but A never gets past sem_wait.
It appears this is due to using a dynamic library, as the code works
fine when I don't use dlopen.
Any thoughts as to how I can get this to work?
Any help would be appreciated,
Bart
| |
| Gianni Mariani 2005-02-15, 4:01 am |
| Orioniz@gmail.com wrote:
>
> It appears this is due to using a dynamic library, as the code works
> fine when I don't use dlopen.
>
> Any thoughts as to how I can get this to work?
> Any help would be appreciated,
This may be system specific. For example, on Linux, if you dlopen a lib
that uses libpthread.so, this causes all kinds of problems. You must
link your executable with libpthread so this gets linked in at process
start-up. There might be other system libraries that may cause similar
problems.
I suggest you look at the .so file you are dlopen()ing and link into the
main executable all the system libraries that are used (or you plan to
use) in the .so file you are dlopen()ing.
(ldd file.so) should give you a list of libs.
BTW - this may not help at all !
|
|
|
|
|