dlopen handles and multiple threads
Matthew Fortune
Matthew.Fortune@imgtec.com
Thu Jul 3 10:22:00 GMT 2014
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
More information about the Libc-alpha
mailing list