日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

【Linux 内核】进程管理 task_struct 结构体 ② ( state 字段 | stack 字段 | pid 字段 | tgid 字段 | pid_links 字段 )

發布時間:2025/6/17 49 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Linux 内核】进程管理 task_struct 结构体 ② ( state 字段 | stack 字段 | pid 字段 | tgid 字段 | pid_links 字段 ) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 一、task_struct 結構體字段分析
    • 1、state 字段
    • 2、stack 字段
    • 3、pid字段
    • 4、tgid 字段
    • 5、pid_links 字段


Linux 內核 中 , " 進程控制塊 " 是通過 task_struct 結構體 進行描述的 ; Linux 內核中 , 所有 進程管理 相關算法邏輯 , 都是基于 task_struct 結構體的 ;

task_struct 結構體在 linux-5.6.18\include\linux\sched.h 頭文件中 第 629629629 ~ 130013001300 行定義 ;





一、task_struct 結構體字段分析




1、state 字段


state 字段表示 進程狀態 ,

  • -1 時表示不可執行 ,
  • 0 表示可執行 ,
  • >0 表示已經停止 ;
/* -1 unrunnable, 0 runnable, >0 stopped: */volatile long state;

2、stack 字段


stack 是一個指針 , 指向 " 內核棧 " ;

void *stack;

3、pid字段


pid 表示該進程的 " 全局進程號 " ;

pid_t pid;

pid_t 是 int 類型的數據 ;

typedef int __kernel_pid_t; #ifndef __kernel_pid_t typedef int __kernel_pid_t; #endif

4、tgid 字段


tgid 表示 " 全局線程組 " 標志 ;

pid_t tgid;

5、pid_links 字段


pid_links 字段 是一個 哈希表 , 其中存放的是 " 進程號 " , 是 " 進程組標識符 "" 會話標識符 " ;

/* PID/PID hash table linkage. */struct pid *thread_pid;struct hlist_node pid_links[PIDTYPE_MAX];struct list_head thread_group;struct list_head thread_node;

總結

以上是生活随笔為你收集整理的【Linux 内核】进程管理 task_struct 结构体 ② ( state 字段 | stack 字段 | pid 字段 | tgid 字段 | pid_links 字段 )的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。