Hi Jaeyong,
On 02.11.2012 05:44, jaeyong yoo wrote:
Hello genode, I have a rather simple question. At any place in source code, how can I know the thread id?
For instance, in the body of main function like,
int main() { ... blah id = some_action_to_get_thread_id(); ... blah }
Best, Jaeyong
In general in Genode there is no notion of a thread id. Although some kernels Genode runs on top of provide thread ids the framework tries to abstract from these. Genode is a capability-based OS framework. That means it tries to avoid system global names (like thread ids), and provides local names (capabilities) instead that are in valid in a corresponding protection-domain only. The idea behind that is: you can only access what you can name.
With respect to threads, there are specific thread-capabilities which belong to a corresponding cpu-session (the one the thread was created by). Using the cpu-session you can do different things with a thread, like stop/resume, getting it's state, destroying it etc.. For most threads (by now the only exception is the first thread of a protection domain) you can obtain it's thread-capability by using the appropriate thread-object via 'Thread::myself()->cap()'.
I hope this clarifies your question. If for some reason you really need the actual thread id of a specific kernel, would you please give some more context about the actual use-case?
Best Regards Stefan