Reputation: 147
When we create a kernel thread using kthread_run()
, how we can get the tid of the thread, is there something like pthread_self()
or gettid()
in kernel space?
Upvotes: 9
Views: 9574
Reputation: 11514
In kernel-space, you don't need to ask something about thread like in userspace you do by calling gettid()
-- you already have access to task_struct
of your task:
struct task_struct* tsk = kthread_run(...);
pid_t tid = tsk->pid; // Thread id of newly created task (if it was successful)
Upvotes: 12