c - kthread_create() 的参数解释
问题描述
我目前正在阅读 Robert Love 的 Linux 内核开发。在阅读有关线程的内容时,我遇到了 kthread_create() 函数,它接受多个参数并相应地生成一个内核线程。
struct task_struct *kthread_create(int (*threadfn)(void *data),
void *data,
const char namefmt[],
...)
据我所知,第一个参数是指向函数的指针,第二个是 threadfn() 的参数,namefmt 是进程的名称。有人可以解释一下最后这些变量参数是什么吗?
解决方案
kthread_create 参数已在内核源代码中进行了解释。 内核源代码中的 kthreade_create 定义
如您所见,namefmt 是一个 printf 样式的格式字符串。意思是
1. namefmt can be a string literal like "my-kernel-thread" and in that
case the variable arguments will not be needed. In this case your
kthread will be named my-kernel-thread
2. namefmt can be a format specifier like "%s-%d" and in that case
variable arguments can be arguments according to this format
specifier. Like for this example they can be "my-kernel-thread",
10. In this case your kthread will be named my-kernel-thread-10
推荐阅读
- .net - 从 Lotus Notes 视图读取下一个文档时出现问题
- java - 这使用了什么类型的加密?
- python - 如何使用 django-allauth 使用谷歌登录链接到我的登录页面?
- python - 在基于 keras 的 LSTM 中,输入形状的特征大小是否小于数据大小?
- python - 基于三元运算符的 luigi 任务
- javascript - 与reduce方法的累加器相关的类型错误
- r - 获取单列变量 Rstudio 的随机替代项
- android - 在没有 Internet 的网络上保持连接
- python - InvalidS3ObjectException:无法从 S3 获取对象元数据?
- reactjs - React Context - 发布喜欢/不喜欢功能