admin管理员组文章数量:1612098
每当看书看到DECLARE_WAITQUEUE(wait, current);总想current是哪来的,写程序的兄弟,对一个不知道来路
的字符或者变量,一般都会有疑问,这应该已经是码农的一种本能.今天又看到这个陌生的家伙,好吧。Source Insight
搞起呗,还有什么好说;废话说真多,写代码就讨厌,繁琐的说一堆.
=> DECLARE_WAITQUEUE(wait, current);
=> #define current get_current()
=> #define get_current() (current_thread_info()->task)
=>
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
__asm__("andl %%esp,%0; ":"=r" (ti) : "0" (~(THREAD_SIZE - 1)));
return ti;
}
=> struct thread_info {
struct task_struct *task; /* main task structure */
struct exec_domain *exec_domain;/* execution domain */
unsigned long flags; /* thread_info flags (see TIF_*) */
mm_segment_t addr_limit; /* user-level address space limit */
__u32 cpu; /* current CPU */
int preempt_count; /* 0=premptable, <0=BUG; will also serve as bh-counter */
struct restart_block restart_block;
};
=> struct struct_task;是内核中一个很重要很重要的结构体.
就跟到这里吧.冰冻三尺非一日之寒,驱动看架构简单,基本里面的程序却是无比的精练.
本文标签: DECLAREWAITQUEUEwaitCurrent
版权声明:本文标题:DECLARE_WAITQUEUE(wait, current)的分析 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1728630331a1167013.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论