I'm using std::thread to launch threads. Also, I need stats for the worker thread available at /proc/[pid]/tasks/[tid]
. I need tid to be able to monitor thread stats. I was wondering if there was a way to extract tid
from the parent thread. I know that syscall gettid() from the worker returns its id, but I want the threadId from the master and not the slave. Is there a way to extract tid
from the thread_id gor from std::thread.get_tid() ?
I believe there might be better ways of doing this, please suggest :)
UPDATE:
How can you get the Linux thread Id of a std::thread() this provides some information on getting tid from the worker, adds an overhead to the thread launch. For instance, std::thread t = std::thread(&wrapper);
t.get_id()
can be called from the launcher thread. I was/am looking if there was a to do the same thing from the main/launcher thread in a safe way.