The data structure of process-related functions is: process descriptor task_struct
This data structure is managed by various waiting queues, execution queues, and so on.
// Below is the task (process) data structure, or process descriptor.
// long state The running state of the task (-1 not runnable, 0 runnable (ready), >0 stopped).
// long counter task runtime count (decrement) (number of ticks), runtime slice.
// long priority number of priorities. When the task starts to run, counter=priority, the larger the run, the longer it will run.
// long signal signal bitmap, each bit represents a signal, signal value = bit offset value + 1.
// struct sigaction sigaction[32] Signal execution attribute structure, corresponding to the operation and flag information to be performed by the signal.
// long blocked process signal mask code (corresponding to signal bitmap).
// -------------------
// int exit_code The exit code of the task execution stop, its parent process will take it.
// unsigned long start_code code segment address.
// unsigned long end_code Code length in bytes.
// unsigned long end_data code length + data length (bytes).
// unsigned long brk Total length in bytes.
// unsigned long start_stack stack segment address.
// long pid process identification number (process number).
// long pgrp Process group number.
// long session session number.
// long leader session leader.
// int groups[NGROUPS] The group number to which the process belongs. A process can belong to multiple groups.
// task_struct *p_pptr pointer to the parent process.
// task_struct *p_cptr Pointer to the latest child process.
// task_struct *p_ysptr Pointer to an adjacent process created after itself.
// task_struct *p_osptr is a pointer to an adjacent process created earlier than itself.
// unsigned short uid User identification number (user id).
// unsigned short euid Effective user id.
// unsigned short suid saves the user id.
// unsigned short gid Group identification number (group id).
// unsigned short egid Effective group id.
// unsigned short sgid holds the group id.
// long timeout kernel timing timeout value.
// long alarm alarm timing value (ticks).
// long utime User mode runtime in ticks.
// long stime System state runtime (number of ticks).
// long cuttime child process user mode running time.
// long cstime child process system state running time.
// long start_time The time when the process starts running.
// struct rlimit rlim[RLIM_NLIMITS] Process resource usage statistics array.
// unsigned int flags; The flags of each process, defined at the beginning of line 149 below (not yet used).
// unsigned short used_math flag: whether the coprocessor is used.
// ------------------------
// int The tty process uses the subdevice number of the tty terminal. -1 means not used.
// unsigned short umask file creation attribute mask bits.
// struct m_inode * pwd current working directory inode structure pointer.
// struct m_inode * root root directory i-node structure pointer.
// struct m_inode * executable executable file inode structure pointer.
// struct m_inode * library Loaded library file inode structure pointer.
// unsigned long close_on_exec closes the file handle bitmap flag when executing. (see include/fcntl.h)
// struct file * filp[NR_OPEN] File structure pointer table, up to 32 items. The entry number is the value of the file descriptor.
// struct desc_struct ldt[3] Local descriptor table. 0-empty, 1-code segment cs, 2-data and stack segment ds&ss.
// struct tss_struct tss process's task status segment information structure.
// ======================================
105 struct task_struct {
106 /* these are hardcoded - don't touch */
107 long state; /* -1 unrunnable, 0 runnable, >0 stopped */
108 long counter;
109 long priority;
110 long signal;
111 struct sigaction sigaction[32];
112 long blocked; /* bitmap of masked signals */
113 /* various fields */
114 int exit_code;
115 unsigned long start_code,end_code,end_data,brk,start_stack;
116 long pid,pgrp,session,leader;
117 int groups[NGROUPS];
118 /*
119 * pointers to parent process, youngest child, younger sibling,
120 * older sibling, respectively. (p->father can be replaced with
121 * p->p_pptr->pid)
122 */
123 struct task_struct *p_pptr, *p_cptr, *p_ysptr, *p_osptr;
124 unsigned short uid, euid, suid;
125 unsigned short gid,egid,sgid;
126 unsigned long timeout,alarm;
127 long utime,stime,cutime,cstime,start_time;
128 struct rlimit rlim[RLIM_NLIMITS];
129 unsigned int flags; /* per process flags, defined below */
130 unsigned short used_math;
131 /* file system info */
132 int tty; /* -1 if no tty, so it must be signed */
133 unsigned short umask;
134 struct m_inode * pwd;
135 struct m_inode * root;
136 struct m_inode * executable;
137 struct m_inode * library;
138 unsigned long close_on_exec;
139 struct file * filp[NR_OPEN];
140 /* ldt for this task 0 - zero 1 - cs 2 - ds&ss */
141 struct desc_struct ldt[3];
142 /* tss for this task */
143 struct tss_struct tss;
144 };
Linux-Process-Data Structure
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325618795&siteId=291194637
Recommended
Ranking