current宏
时间:2011-07-14
来源:互联网
在x86的<asm/current.h>中
C/C++ code
percpu_read_stable(current_task)这句看不懂,从这句往后追踪,也看不懂,求解释
为什么不是通过current_thread_info得到
C/C++ code
#ifndef _ASM_X86_CURRENT_H #define _ASM_X86_CURRENT_H #include <linux/compiler.h> #include <asm/percpu.h> #ifndef __ASSEMBLY__ struct task_struct; DECLARE_PER_CPU(struct task_struct *, current_task); static __always_inline struct task_struct *get_current(void) { return percpu_read_stable(current_task); } #define current get_current() #endif /* __ASSEMBLY__ */ #endif /* _ASM_X86_CURRENT_H */
percpu_read_stable(current_task)这句看不懂,从这句往后追踪,也看不懂,求解释
为什么不是通过current_thread_info得到
作者: proghua 发布时间: 2011-07-14
猜测一下,供参考:
DECLARE_PER_CPU(struct task_struct *, current_task);
----这个宏应该是声明了一个struct task_struct *类型的结构体,名字叫current_task,这个结构体应该是指示任务属性的
static __always_inline struct task_struct *get_current(void)
{
return percpu_read_stable(current_task);
}
----这个函数需要返回一个struct task_struct *类型的结构体指针,即获取现在的任务属性,于是调用percpu_read_stable函数,这个函数的参数是刚才声明的current_task,在percpu_read_stable函数内部应该会用各种参数填充刚才声明的current_task,然后把这个current_task返回回来
DECLARE_PER_CPU(struct task_struct *, current_task);
----这个宏应该是声明了一个struct task_struct *类型的结构体,名字叫current_task,这个结构体应该是指示任务属性的
static __always_inline struct task_struct *get_current(void)
{
return percpu_read_stable(current_task);
}
----这个函数需要返回一个struct task_struct *类型的结构体指针,即获取现在的任务属性,于是调用percpu_read_stable函数,这个函数的参数是刚才声明的current_task,在percpu_read_stable函数内部应该会用各种参数填充刚才声明的current_task,然后把这个current_task返回回来
作者: thefirstz 发布时间: 2011-07-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28