Linux task_struct is used to control the management process, the structure is as follows: struct TASK_STRUCT {//Indicates whether the process can be executed, or can be interrupted and other information volatile long state; Flage is the process number that is given when the fork () is called unsigned long flags; Process on whether the signal to be processed int sigpending; Process address space, distinguish between the kernel process and the normal process in memory storage location of different mm_segment_t addr_limit; 0-0XBFFFFFFF for User-thead//0-0xffffffff for Kernel-thread//dispatch flag indicating whether the process needs to be re-dispatched, if not 0, when the When the kernel state returns to the user state, the dispatch volatile long need_resched will occur; Lock depth int lock_depth; Basic time slice of process long nice; Process scheduling strategy, there are three kinds, real-time process: SCHED_FIFO,SCHED_RR, Timeshare process: sched_other unsigned long policy; Process memory Management information struct mm_struct *mm; int processor; If the process is not running on any CPU, the value of cpus_runnable is 0, otherwise 1 This value is updated unsigned long cpus_runnable, cpus_allowed when running the queue is locked; Pointer to the run queue struct list_head run_list; Process sleep time unsigned long sleep_time; Used to connect all the processes in the system into a two-way circular linked list whose root is init_task struct task_struct *next_task, *prev_task; struct Mm_struct *active_mm; struct List_head local_pages; Point to local page unsigned int allocation_order, nr_local_pages; struct LINUX_BINFMT *binfmt; The format of the executable file that the process runs in int exit_code, exit_signal; int pdeath_signal; Parent process termination is a signal sent to a subprocess unsigned long personality; Linux can run programs that are generated by other Unix operating systems that conform to the IBCS2 standard, int did_exec:1; pid_t pid; The process identifier used to represent a process pid_t pgrp; The process group identity that represents the process group to which the process belongs pid_t tty_old_pgrp; The group identifier of the Process Control terminal is pid_t session; Session ID of the process pid_t tgid; int leader; Indicates whether the process is a session leader, struct task_struct *p_opptr,*p_pptr,*p_cptr,*p_ysptr,*p_osptr; struct List_head thread_group; Line threads struct Task_struct *pidhash_next; Used to chain the process into the hash table struct task_struct **pidhash_pprev; wait_queue_head_t Wait_chldexit; For WAIT4 () use struct completion *vfork_done; For vfork () use unsigned long rt_priority; Real-time priority, which calculates the weight value of real-time process scheduling//IT_REAL_VALUE,IT_REAL_INCR for the real timer, in Jiffies, the system based on the It_real_value//Set the first stop time of the timer. When the timer expires, send the SIGALRM signal to the process, and according to the//IT_REAL_INCR reset termination time, IT_PROF_VALUE,IT_PROF_INCR for the profile timer, the unit is jiffies. When the process is running, each tick causes the It_prof_value value to be reduced by one, regardless of state, and when it is reduced to 0 o'clock, sends//signals to the process sigprof and resets the time according to IT_PROF_INCR. The It_virt_value,it_virt_value is used for virtual timers in jiffies units. WhenWhile the process is running, each tick causes the It_virt_value value to be reduced by one to 0 o'clock, sending a signal sigvtalrm to the process, and resetting the initial value according to//IT_VIRT_INCR, regardless of the//state. 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; Pointer to real-time timer struct TMS times; Record the time consumed by the process unsigned long start_time; The time the process was created//record the user-state time and kernel-mentality time consumed by the process on each CPU long Per_cpu_utime[nr_cpus], Per_cpu_stime[nr_cpus]; Memory page faults and exchange information://min_flt, Maj_flt number of secondary pages of the cumulative process (Copy on write and anonymous pages) and number of primary pages (number of pages read from a mapping file or interchange//device); Nswap the number of pages that the process accumulates. That is, the number of pages written to the switching device. Cmin_flt, Cmaj_flt, Cnswap records the cumulative number of page faults for all descendants of the ancestor process, the number of main pages and the number of pages swapped out. When the parent process recycles the terminated child process, the parent process accumulates this information for the child process into those domains of its own structure unsigned long min_flt, Maj_flt, Nswap, Cmin_flt, Cmaj_flt, Cnswap; int swappable:1; Indicates whether the virtual address space of the process allows for swapping out//process authentication information//uid,gid The user identifier and group identifier of the user running the process, usually the Uid,gid//euid,egid of the process creator as a valid Uid,gid//fsuid, Fsgid is file system Uid,gid, these two ID numbers are usually equal to valid uid,gid, and they are used when checking access rights to files//systems. Suid,sgid for backup Uid,gid uid_t Uid,euid,suid,fsuid; gid_t Gid,egid,sgid,fsgid; int ngroups; Record how many user groups the process gid_t groups[nGROUPS]; Record the group that the process is in//the power of the process, respectively, is a valid bit set, inheritance bit set, allow bit set kernel_cap_t cap_effective, cap_inheritable, cap_permitted; int keep_capabilities:1; struct User_struct *user; struct Rlimit rlim[rlim_nlimits]; Process-related resource restriction information unsigned short used_math; Whether to use FPU char comm[16]; The executable file name//file system information that the process is running int link_count, total_link_count; Null if no TTY process is located in the control terminal, if the control terminal is not required, then the pointer is an empty struct tty_struct *tty; unsigned int locks; Inter-process communication information struct Sem_undo *semundo; All undo operations of the process on the semaphore are struct sem_queue *semsleeping; When the process is suspended because of a semaphore operation, he logs the CPU status of the waiting operation//process in the queue, and when switching, the struct thread_struct thread is saved to the task_struct of the stop process; File system Information struct fs_struct *fs; Open file information struct files_struct *files; Signal processing function spinlock_t Sigmask_lock; struct Signal_struct *sig; Signal processing function sigset_t blocked; A signal that the process is currently blocking, with each signal corresponding to a struct sigpending pending; Whether the process is pending signal unsigned long sas_ss_sp; size_t Sas_ss_size; Int (*notifier) (void *priv); void *notifier_data; sigset_t *notifier_mask; U32 parent_exec_id; U32 self_exec_id; spinlock_t alloc_lOck; void *journal_info; };
Process Control block PCB-------task_struct structure in Linux