嵌入式Linux中文站收集整理Linux0.11版本內(nèi)核學(xué)習(xí)筆記,本文分析了Linux進(jìn)程控制模塊的數(shù)據(jù)結(jié)構(gòu)。
struct?task_struct?{??
long?state??
//任務(wù)的運(yùn)行狀態(tài)(-1?不可運(yùn)行,0?可運(yùn)行(就緒),>0?已停止)。??
long?counter??
//?任務(wù)運(yùn)行時(shí)間計(jì)數(shù)(遞減)(滴答數(shù)),運(yùn)行時(shí)間片。??
long?priority??
//?運(yùn)行優(yōu)先數(shù)。??
任務(wù)開始運(yùn)行時(shí)?counter=priority,??
越大運(yùn)行越長。??
long?signal??
//?信號(hào)。是位圖,每個(gè)比特位代表一種信號(hào),信號(hào)值=位偏移值+1。??
struct?sigaction?sigaction[32]?//?信號(hào)執(zhí)行屬性結(jié)構(gòu),對應(yīng)信號(hào)將要執(zhí)行的操作和標(biāo)志信息。??
long?blocked??
//?進(jìn)程信號(hào)屏蔽碼(對應(yīng)信號(hào)位圖)。??
int?exit_code??
//?任務(wù)執(zhí)行停止的退出碼,其父進(jìn)程會(huì)取。??
//?代碼段地址。??
unsigned?long?start_code??
unsigned?long?end_code??
//?代碼長度(字節(jié)數(shù))。??
unsigned?long?end_data??
//?代碼長度?+?數(shù)據(jù)長度(字節(jié)數(shù))。??
unsigned?long?brk??
//?總長度(字節(jié)數(shù))。??
unsigned?long?start_stack??
//?堆棧段地址。??
long?pid??
//?進(jìn)程標(biāo)識(shí)號(hào)(進(jìn)程號(hào))。??
long?father??
//?父進(jìn)程號(hào)。??
long?pgrp??
//?父進(jìn)程組號(hào)。??
long?session??
//?會(huì)話號(hào)。??
long?leader??
//?會(huì)話首領(lǐng)。??
unsigned?short?uid??
//?用戶標(biāo)識(shí)號(hào)(用戶?id)。??
unsigned?short?euid??
//?有效用戶?id。??
unsigned?short?suid??
//?保存的用戶?id。??
unsigned?short?gid??
//?組標(biāo)識(shí)號(hào)(組?id)。??
unsigned?short?egid??
//?有效組?id。??
unsigned?short?sgid??
//?保存的組?id。??
long?alarm??
//?報(bào)警定時(shí)值(滴答數(shù))。??
long?utime??
//?用戶態(tài)運(yùn)行時(shí)間(滴答數(shù))。??
long?stime??
//?系統(tǒng)態(tài)運(yùn)行時(shí)間(滴答數(shù))。??
long?cutime??
//?子進(jìn)程用戶態(tài)運(yùn)行時(shí)間。??
long?cstime??
//?子進(jìn)程系統(tǒng)態(tài)運(yùn)行時(shí)間。??
long?start_time??
//?進(jìn)程開始運(yùn)行時(shí)刻。??
unsigned?short?used_math??
//?標(biāo)志:是否使用了協(xié)處理器。??
int?tty??
//?進(jìn)程使用?tty?的子設(shè)備號(hào)。-1?表示沒有使用。??
unsigned?short?umask??
//?文件創(chuàng)建屬性屏蔽位。??
struct?m_inode?*?pwd??
//?當(dāng)前工作目錄?i?節(jié)點(diǎn)結(jié)構(gòu)。??
struct?m_inode?*?root??
//?根目錄?i?節(jié)點(diǎn)結(jié)構(gòu)。??
struct?m_inode?*?executable?//?執(zhí)行文件?i?節(jié)點(diǎn)結(jié)構(gòu)。??
unsigned?long?close_on_exec?//?執(zhí)行時(shí)關(guān)閉文件句柄位圖標(biāo)志。(參見?include/fcntl.h)??
struct?file?*?filp[NR_OPEN]?//?文件結(jié)構(gòu)指針表,最多?32?項(xiàng)。表項(xiàng)號(hào)即是文件描述符的值。??
struct?desc_struct?ldt[3]?//?任務(wù)局部描述符表。0-空,1-代碼段?cs,2-數(shù)據(jù)和堆棧段?ds&ss。??
struct?tss_struct?tss??
//?進(jìn)程的任務(wù)狀態(tài)段信息結(jié)構(gòu)。??
};??
struct task_struct {long state//任務(wù)的運(yùn)行狀態(tài)(-1 不可運(yùn)行,0 可運(yùn)行(就緒),>0 已停止)。long counter// 任務(wù)運(yùn)行時(shí)間計(jì)數(shù)(遞減)(滴答數(shù)),運(yùn)行時(shí)間片。long priority// 運(yùn)行優(yōu)先數(shù)。任務(wù)開始運(yùn)行時(shí) counter=priority,越大運(yùn)行越長。long signal// 信號(hào)。是位圖,每個(gè)比特位代表一種信號(hào),信號(hào)值=位偏移值+1。struct sigaction sigaction[32] // 信號(hào)執(zhí)行屬性結(jié)構(gòu),對應(yīng)信號(hào)將要執(zhí)行的操作和標(biāo)志信息。long blocked// 進(jìn)程信號(hào)屏蔽碼(對應(yīng)信號(hào)位圖)。int exit_code// 任務(wù)執(zhí)行停止的退出碼,其父進(jìn)程會(huì)取。// 代碼段地址。unsigned long start_codeunsigned long end_code// 代碼長度(字節(jié)數(shù))。unsigned long end_data// 代碼長度 + 數(shù)據(jù)長度(字節(jié)數(shù))。unsigned long brk// 總長度(字節(jié)數(shù))。unsigned long start_stack// 堆棧段地址。long pid// 進(jìn)程標(biāo)識(shí)號(hào)(進(jìn)程號(hào))。long father// 父進(jìn)程號(hào)。long pgrp// 父進(jìn)程組號(hào)。long session// 會(huì)話號(hào)。long leader// 會(huì)話首領(lǐng)。unsigned short uid// 用戶標(biāo)識(shí)號(hào)(用戶 id)。unsigned short euid// 有效用戶 id。unsigned short suid// 保存的用戶 id。unsigned short gid// 組標(biāo)識(shí)號(hào)(組 id)。unsigned short egid// 有效組 id。unsigned short sgid// 保存的組 id。long alarm// 報(bào)警定時(shí)值(滴答數(shù))。long utime// 用戶態(tài)運(yùn)行時(shí)間(滴答數(shù))。long stime// 系統(tǒng)態(tài)運(yùn)行時(shí)間(滴答數(shù))。long cutime// 子進(jìn)程用戶態(tài)運(yùn)行時(shí)間。long cstime// 子進(jìn)程系統(tǒng)態(tài)運(yùn)行時(shí)間。long start_time// 進(jìn)程開始運(yùn)行時(shí)刻。unsigned short used_math// 標(biāo)志:是否使用了協(xié)處理器。int tty// 進(jìn)程使用 tty 的子設(shè)備號(hào)。-1 表示沒有使用。unsigned short umask// 文件創(chuàng)建屬性屏蔽位。struct m_inode * pwd// 當(dāng)前工作目錄 i 節(jié)點(diǎn)結(jié)構(gòu)。struct m_inode * root// 根目錄 i 節(jié)點(diǎn)結(jié)構(gòu)。struct m_inode * executable // 執(zhí)行文件 i 節(jié)點(diǎn)結(jié)構(gòu)。unsigned long close_on_exec // 執(zhí)行時(shí)關(guān)閉文件句柄位圖標(biāo)志。(參見 include/fcntl.h)struct file * filp[NR_OPEN] // 文件結(jié)構(gòu)指針表,最多 32 項(xiàng)。表項(xiàng)號(hào)即是文件描述符的值。struct desc_struct ldt[3] // 任務(wù)局部描述符表。0-空,1-代碼段 cs,2-數(shù)據(jù)和堆棧段 ds&ss。struct tss_struct tss// 進(jìn)程的任務(wù)狀態(tài)段信息結(jié)構(gòu)。};?
其中的 m_inode數(shù)據(jù)結(jié)構(gòu)如下
struct?m_inode?{??
unsigned?short?i_mode;??
unsigned?short?i_uid;??
unsigned?long?i_size;??
unsigned?long?i_mtime;??
unsigned?char?i_gid;??
unsigned?char?i_nlinks;??
unsigned?short?i_zone[9];??
/*?these?are?in?memory?also?*/??
struct?task_struct?*?i_wait;??
unsigned?long?i_atime;??
unsigned?long?i_ctime;??
unsigned?short?i_dev;??
unsigned?short?i_num;??
unsigned?short?i_count;??
unsigned?char?i_lock;??
unsigned?char?i_dirt;??
unsigned?char?i_pipe;??
unsigned?char?i_mount;??
unsigned?char?i_seek;??
unsigned?char?i_update;??
};??
struct m_inode {unsigned short i_mode;unsigned short i_uid;unsigned long i_size;unsigned long i_mtime;unsigned char i_gid;unsigned char i_nlinks;unsigned short i_zone[9];/* these are in memory also */struct task_struct * i_wait;unsigned long i_atime;unsigned long i_ctime;unsigned short i_dev;unsigned short i_num;unsigned short i_count;unsigned char i_lock;unsigned char i_dirt;unsigned char i_pipe;unsigned char i_mount;unsigned char i_seek;unsigned char i_update;};?
?
評(píng)論
查看更多