2.4 내부 핵 중 taskstruct 구조 체 전해

/*  :http://wenku.baidu.com/view/9132d213f18583d049645902.html*/


********************************************



      ,                       ,  ,       

             ,                        。

 linux   ,   task_struct  , include\linux\sched.h     。



           task_struct  ,             ,

                    。

     linux            ,          。



         :



	1、     ,        ,  ,   

	2、    ,          ,     

	3、       

	4、        ,            ,    task_struct 

	5、    ,           ,   cpu   

	6、   ,       

	7、             

	8、            

	9、      

	10、    





==========================================================================







  /include/linux/sched.h    task_struct    



struct task_struct {



	volatile long state;     			            ,        

	unsigned long flags; 				Flage     ,   fork()   

	int sigpending; 						            



----------------------------------------

	mm_segment_t addr_limit;               

		      ,                     

		0-0xBFFFFFFF for user-thead    

		0-0xFFFFFFFF for kernel-thread 

----------------------------------------

	volatile long need_resched;

		    ,             ,

		   0,               ,     

----------------------------------------

	int lock_depth; 						   

	long nice;         

----------------------------------------

	unsigned long policy;

		       ,   

		    :SCHED_FIFO,SCHED_RR

		    :SCHED_OTHER

----------------------------------------

	struct mm_struct mm;           	         

----------------------------------------

	int processor;

		       CPU   ,

		cpus_runnable    0,   1。

		             .

----------------------------------------

	unsigned long cpus_runnable, cpus_allowed;

	struct list_head run_list;		 					         

	unsigned long sleep_time; 							       

----------------------------------------

	struct task_struct next_task, prev_task;

		                     

		   init_task.

----------------------------------------

	struct mm_struct active_mm;

	truct list_head local_pages;						      

	unsigned int allocation_order, nr_local_pages;

	struct linux_binfmt binfmt;				              

	int exit_code, exit_signal;

	int pdeath_signal;							               

	unsigned long personality;

	Linux						       UNIX         iBCS2     

----------------------------------------

	int did_exec:1;

		 POSIX        ,         

		         ,     execve        

----------------------------------------

	pid_t pid;								     ,        

	pid_t pgrp;							     ,          

	pid_t tty_old_pgrp;						            

	pid_t session;											       

	pid_t tgid;

	int leader; 								  ,           

----------------------------------------

	struct task_struct p_opptr,p_pptr,p_cptr,p_ysptr,p_osptr;

	struct list_head thread_group; 							    

	struct task_struct pidhash_next;		       HASH pidhash



----------------------------------------

	struct task_struct pidhash_pprev;

	wait_queue_head_t wait_chldexit; 				 wait4()  

	struct completion vfork_done;  					 vfork()   

----------------------------------------

	unsigned long rt_priority;

	     ,            weight ,

----------------------------------------

	it_real_value,it_real_incr;				  REAL   ,   jiffies

    it_real_value //             。

       ,     SIGALRM  ,    

it_real_incr      ,it_prof_value,it_prof_incr

  Profile   ,   jiffies。      ,

        ,  tick  it_prof_value   ,

   0 ,       SIGPROF,   it_prof_incr    

it_virt_value,it_virt_value  Virtual   ,   jiffies。

      ,        ,  tick  it_virt_value   

   0 ,       SIGVTALRM,  it_virt_incr    。

Real             ,         

Virtual          ,               

Profile         ,        

(           )  



----------------------------------------

	unsigned long it_real_value, it_prof_value, it_virt_value;

	unsigned long it_real_incr, it_prof_incr, it_virt_value;

	struct timer_list real_timer;//          

	struct tms times; //         ,

	unsigned long start_time;//       

	long per_cpu_utime[NR_CPUS], per_cpu_stime[NR_CPUS]; //       CPU                

----------------------------------------



 mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific 

//         :

//min_flt, maj_flt         (Copy on Write     )     (                );

//nswap            ,            。

//cmin_flt, cmaj_flt, cnswap                      ,          。    

//         ,                         

unsigned long min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;

int swappable:1; //                 

 process credentials ///      

//uid,gid                    ,         uid,gid //euid,egid   uid,gid

//fsuid,fsgid     uid,gid,   ID      uid,gid  ,                   。

//suid,sgid   uid,gid

uid_t uid,euid,suid,fsuid;

gid_t gid,egid,sgid,fsgid;

int ngroups; //            

gid_t groups[NGROUPS]; //        

kernel_cap_t cap_effective, cap_inheritable, cap_permitted;//     ,        ,     ,     

int keep_capabilities:1;

struct user_struct user;

 limits 

struct rlimit rlim[RLIM_NLIMITS]; //            

unsigned short used_math; //    FPU

char comm[16]; //             

 file system info //      

int link_count, total_link_count;

struct tty_struct tty;  NULL if no tty          ,         ,      

unsigned int locks;  How many file locks are being held 

 ipc stuff //       

struct sem_undo semundo; //          undo  

struct sem_queue semsleeping; //              ,             

 CPU-specific state of this task //   CPU  ,   ,         

task_struct 

struct thread_struct thread;

 filesystem information      

struct fs_struct fs;

 open file information //      

struct files_struct files;

 signal handlers //      

spinlock_t sigmask_lock;  Protects signal and blocked 

struct signal_struct sig; //      ,

sigset_t blocked; //          ,        

struct sigpending pending; //            

unsigned long sas_ss_sp;

size_t sas_ss_size;

int (notifier)(void priv);

void notifier_data;

sigset_t notifier_mask; Thread group tracking 

u32 parent_exec_id;

u32 self_exec_id;

 Protection of (de-)allocation: mm, files, fs, tty 

spinlock_t alloc_lock;

void journal_info; journalling filesystem info 

};















********************************************

좋은 웹페이지 즐겨찾기