Process Control block PCB-------task_struct structure in Linux

Source: Internet
Author: User
Tags bit set session id semaphore volatile

Linux task_struct is used to control the management process with the following structure:

struct TASK_STRUCT
{
Describes whether the process can be executed, or can be interrupted, and other information
volatile long state;
Flage is the process number, given when the fork () is called
unsigned long flags;
Whether the process is waiting for a signal to be processed
int sigpending;
Process address space, which distinguishes between kernel processes and normal processes where memory is stored
mm_segment_t Addr_limit; 0-0XBFFFFFFF for User-thead
0-0XFFFFFFFF for Kernel-thread

A dispatch flag that indicates whether the process needs to be re-dispatched, or not 0, when it is returned from the kernel state to the user state, a dispatch occurs
volatile long need_resched;
Lock depth
int lock_depth;
Basic time slices of the 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 when the running queue is locked
unsigned long cpus_runnable, cpus_allowed;
Pointer to run queue
struct List_head run_list;
Sleep time of the process
unsigned long sleep_time;

Used to connect all 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
int Exit_code, exit_signal;
int pdeath_signal; Parent process termination is a signal sent to a child process
unsigned long personality;
Linux can run programs that meet IBCS2 standards generated by other UNIX operating systems
int did_exec:1;
pid_t pid; A process identifier that is used to represent a process
pid_t pgrp; Process group identity, which represents the process group to which the process belongs
pid_t tty_old_pgrp; The group ID where the process control terminal resides
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 a process into a 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 for real-time process scheduling
IT_REAL_VALUE,IT_REAL_INCR for real timers, unit jiffies, system based on It_real_value

Sets the first stop time of the timer. When the timer expires, send the SIGALRM signal to the process, and according to

IT_REAL_INCR Reset termination time, IT_PROF_VALUE,IT_PROF_INCR for the profile timer, Unit jiffies.

When the process runs, each tick causes the It_prof_value value to be reduced by one at any state, and when it is reduced to 0 o'clock, the process is sent

The signal sigprof and resets the time according to the IT_PROF_INCR.
The It_virt_value,it_virt_value is used for virtual timers in jiffies units. When the process is running, no matter what

State, each tick causes the It_virt_value value to be reduced by one to 0 o'clock, sending a signal to the process sigvtalrm, depending on

IT_VIRT_INCR resets the initial value.

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 that the process consumes
unsigned long start_time; Time the process was created

Log the user-state time and the kernel-mentality time consumed by the process on each CPU
Long Per_cpu_utime[nr_cpus], Per_cpu_stime[nr_cpus];
Memory pages and exchange information:

Min_flt, Maj_flt number of secondary pages of the cumulative process (Copy on write and anonymous pages) and the number of main page pages (from the mapping file or interchange

The number of pages that the device reads); Nswap records 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 swapping out
Process authentication Information
Uid,gid is the user identifier and group identifier of the user running the process, usually the uid,gid of the process creator

Euid,egid for effective Uid,gid
Fsuid,fsgid for file system Uid,gid, these two ID numbers are usually equal to valid uid,gid, check for file

Use them when accessing the system.
Suid,sgid for backup Uid,gid
uid_t Uid,euid,suid,fsuid;
gid_t Gid,egid,sgid,fsgid;
int ngroups; How many user groups the recording process is in
gid_t Groups[ngroups]; Record the group in which the process resides

The power of the process, respectively, is the set of valid bits, the set of inherited bits, the allowed 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 throttling information
 unsigned short used_math;  // Whether to use the FPU
 char comm[16];  //process running executable file name
 //file System Information
 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 empty
struct Tty_struct *tty;
unsigned int locks;
Inter-process communication information
struct Sem_undo *semundo; All undo actions on the semaphore by the process
struct Sem_queue *semsleeping; When the process is suspended because of a semaphore operation, he logs the pending action in that queue
CPU state of the process, when switching, to be saved to the task_struct of the stop process
struct THREAD_STRUCT thread;
File System Information
struct Fs_struct *fs;
Open File Information
struct Files_struct *files;
Signal processing functions
spinlock_t Sigmask_lock;
struct Signal_struct *sig; Signal processing functions
sigset_t blocked; The signal that the process is currently blocking, with each signal corresponding to one
struct sigpending pending; Whether the process is waiting for a signal to be processed
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;
};

The TASK_STRUCT structure in this blog is derived from http://blog.csdn.net/jurrah/archive/2009/03/07/3965437.aspx

Process Control block PCB-------task_struct structure in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.