This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dlopen handles and multiple threads


Hi all,

Can anyone tell me with confidence whether either of the following scenarios are valid relating to sharing code between threads:

== Scenario 1 ==
I have two threads running.
Thread 1 dlopens a library which is not already loaded
Thread 1 places the handle to this library into a global variable
Thread 1 notifies thread 2 that the handle is available (by whatever mechanism)
Thread 2 performs a dlsym on the handle to find a function
Thread 2 executes the function

== Scenario 2 ==
I have two threads running.
Thread 1 dlopens a library which is not already loaded
Thread 1 performs a dlsym on that handle to find a function
The function pointer is stored in a global variable
Thread 1 notifies thread 2 that the function pointer is available (by whatever mechanism)
Thread 2 executes the function

I believe the answer is that they are both perfectly valid, but I have reason to hope that at least scenario 2 is invalid.

I am aware/think that the following scenario is valid:

== Scenario 3 ==
I have two threads running.
Thread 1 dlopens a library which is not already loaded
Thread 2 dlopens the same library and gets given a handle to the already loaded library
Thread 2 performs a dlsym on the handle to find a function
Thread 2 executes the function

Thanks,
Matthew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]