Hi all,
If we want to use thread specific data in a multithreaded application, how to access those data from another collector thread periodically? Is it possible?
Regards Ram
Hi all,
If we want to use thread specific data in a multithreaded application, how to access those data from another collector thread periodically? Is it possible?
Regards Ram
Yes, all the threads in the process (application) share the same memory. Just give the address of the data to the collector thread. Be careful with concurrent access: reading some parts of the memory while it's being updated. You might need to protect some memory zones with mutex.
Under certain systems it is possible to create variables in so-called thread-local storage. Gcc manual explains how you can achieve it and provides the link to Drepper's article, that explains technical details. This is a C standard extension, so under your system there should be a different mechanism.