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