[Linux] Linux Process PID Hash table

Source: Internet
Author: User

Each process in a Linux system is identified by a process ID, a process descriptor that corresponds to a task_struct structure in the kernel, and the task_struct of all processes in the system are linked through a chain table, and in the kernel it is often necessary to get the process descriptor through the process ID. The simplest method can be obtained by traversing the Task_struct list and comparing the value of the ID, but this is too inefficient, especially if there are many processes running in the system.

The Linux kernel solves this problem by using a PID hash list , which can quickly get to the process descriptor through the process ID .

The PID hash list contains 4 tables because the process descriptor contains fields that represent different types of PID, and each type of PID requires its own hash table.

enum pid_type{        pidtype_pid,  // pid of process pid        /  thread Group lead process //  Process Group lead process PID   pidtype_sid,//            PID        pidtype_max   //  type number of Session lead process };

View/proc/pid/status to see the current status of some processes:

[Email Protected]:/proc/19280/task $ cat 19282/status Name:gcstate:s (sleeping) Tgid:19280Pid:19282PPid:17974Tracerpid:0Uid:10043 10043 10043 10043Gid:10043 10043 10043 10043fdsize:256Groups:1006 1007 1015 1028 3001 3002 3003Vmpeak:483560kbvmsize:481500Kbvmlck:0Kbvmpin:0KBVMHWM:44940Kbvmrss:29684Kbvmdata:24848KBVMSTK:136Kbvmexe:8Kbvmlib:29096Kbvmpte:160Kbvmswap:0kbthreads:19Sigq:0/5987SIGPND:0000000000000000SHDPND:0000000000000000sigblk:0000000000001204sigign:0000000000000000Sigcgt:00000002000094e8capinh:0000000000000000CAPPRM:0000000000000000Capeff:0000000000000000capbnd:ffffffffffffffffcpus_allowed:3cpus_allowed_list:0-1voluntary_ctxt_switches:5nonvoluntary_ctxt_switches:33

[Linux] Linux Process PID Hash table

Related Article

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.