DECLARE_WAITQUEUE(wait, current)的分析

每当看书看到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;是内核中一个很重要很重要的结构体.

就跟到这里吧.冰冻三尺非一日之寒,驱动看架构简单,基本里面的程序却是无比的精练.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值