如何访问当前从用户空间读取/写入的线程数? [英] How to access the number of threads currently reading/writing form the userspace?

查看:99
本文介绍了如何访问当前从用户空间读取/写入的线程数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个模块,用户可以在其中读取或写入proc文件-如何确定在内核级编程中读取或写入的用户进程中的线程数?

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?

推荐答案

在您的读/写函数中,将current用作指向当前任务(当前task_struct)的指针:

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
}

这篇关于如何访问当前从用户空间读取/写入的线程数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆