12-15 Process Data Structure

Tasks task
- managed by task_struct
- Job ID, there pid, tgid
-PID & TPID difference
getpid is acquired in the process descriptor task_struct tgid (thread group identifier), the pid (process identifier) ​​is to manage all system processes id
Signal Processing
Processing status:
-blocked blocked, not processed
-pending wait, do not deal with
-sighand function by processing signals
 
Task state: (a geometric square 2)
#define TASK_DEAD 64
#define TASK_WAKEKILL 128
#define TASK_WAKING 256
#define TASK_PARKED 512
#define TASK_NOLOAD 1024
#define TASK_NEW 2048
#define TASK_STATE_MAX 4096
Sleep:
- can interrupt sleep patterns;
- uninterruptible sleep mode
 
 
 
First, check the running status information
1. Display the front CPU 10 of processes;
ps auxw|head -1;ps auxw|sort -rn -k3|head -10
2. Display of processes before Mem 10
ps auxw|head -1;ps auxw|sort -rn -k4|head -10
3.dstat usage
dstat -c
4.top
Second, inter-process relationships
-parent process
-children process
-sibling process
 
Third, Process Rights
objective/subjective
cred/real_cred ##cred<-> subjective; Real_cred<->objective
1)用户和用户组控制权限
- uid,gid
-euid ,egid
-fsuid,fsgid
2) capabilities 可以让普通用户获得更高权限,同时又不赋予root权限;
-cap_permited
-cap_effective
-cap_inheritable
-cap_bset
-cap_ambient ##解决cap_inheritable短板。
 
四、内存管理
mm_struct
1.用户态函数栈
-后进先出原则,即函数调用通过栈完成;
-入栈(push)和出栈(POP) 都是从栈顶进入,栈都是从高地址往低地址,往下增长的结构
 
-32位 叫ESP(栈顶) 和EBP(栈基),用的全部是函数栈;
-64位叫 RSP 和RBP,前6个使用寄存器;其他用函数栈;
-栈都是在内存空间完成
 
2. 内核态函数栈, 和进程运行有关。
- 32位;定义:arch/x86/include/asm/page_32_types.h
-PAGE_SIZE:4K;8k
-64位;定义:arch/x86/include/asm/page_64_types.h
-PAGE_SIZE:8k,16k,起始地址为8192的整数倍
-内核的代码Union将Thread_info和stack 放在一起,代码路径:include/linux/sched.h
-代码最高地址端,存放在另一个结构,pt_regs内;
-32位内核栈用thread_info来关联task_struct, 64位用per-CPU

 

Guess you like

Origin www.cnblogs.com/JaPer/p/10937174.html