PinkElephantsOnParade
PinkElephantsOnParade

Reputation: 6592

How to access the number of threads currently reading/writing form the userspace?

I have written a module where a user can read or write to a proc file - how do I determine the number of threads in a user process that is reading or writing in kernel-level programming?

Upvotes: 3

Views: 478

Answers (1)

Ilya Matveychikov
Ilya Matveychikov

Reputation: 4024

Use current as a pointer to the current task (current task_struct) inside your read/write function:

#include <linux/sched.h>

struct task_struct * t;
for (t = next_thread(current); t != current; t = next_thread(t)) {
    // do the stuff
}

Upvotes: 6

Related Questions