进程最常用的是进程描述符结构task_struct而不是thread_info结构的地址。为了获取当前CPU上运行进程的task_struct结构,内核提供了current宏,由于task_struct *task在thread_info的起始位置,该宏本质上等价于current_thread_info()->task,在include/asm-generic/current.h中定义: #define get_current() (current_thread...
struct thread_info *thread_info: 线程信息。 pid_tpid: 进程ID。 struct task_struct *parent: 指向父进程的指针。 struct list_head children: 子进程链表头部。 structmm_struct*mm: 进程地址空间描述符。 struct files_struct *files: 文件描述符表指针。 进程状态 /* * Task state bitmask. NOTE! These...
由代码可见,这里根据架构不同可能采用旧版的task_struct直接放在内核栈,而新版的均采用thread_info,以节约空间。 union thread_union { #ifndef CONFIG_ARCH_TASK_STRUCT_ON_STACK struct task_struct task; #endif #ifndef CONFIG_THREAD_INFO_IN_TASK struct thread_info thread_info; #endif unsigned long ...
它的值通常与real_parent相同 */ struct task_struct *real_parent; struct task_struct *parent; /* 3) children: 表示链表的头部,链表中的所有元素都是它的子进程(子进程链表) 4) sibling: 用于把当前进程插入到兄弟链表中(连接到父进程的子进程链表(兄弟链表)) 5) group_leader: 指向其所在进程组的领头...
linux进程描述符—task_struct结构 为了管理进程,操作系统必须对每个进程所做的事情进行清楚地描述,为此,操作系统使用数据结构来代表处理不同的实体,这个数据结构就是通常所说的进程描述 符或进程控制块,在linux系统中,这就是task_struct结构,在include\linux\sched.h文件中定义。每个进程都会被分配 一个task_struct结...
struct task_struct *group_leader; 1. 2. 3. 4. 5. linux系统当中,考虑到进程的派生,所以进程之间会存在父进程和子进程这样的关系,当然,对于同一个父进程派生出来的进程,他们的关系当然是兄弟进程了。 1.6 ptrace系统调用 unsigned int ptrace; struct list_head ptraced; ...
进程最常用的是进程描述符结构task_struct而不是thread_info结构的地址。为了获取当前CPU上运行进程的task_struct结构,内核提供了current宏,由于task_struct *task在thread_info的起始位置,该宏本质上等价于current_thread_info()->task,在include/asm-generic/current.h中定义: ...
task_struct ├──ProcessIdentification │├──pid:processid,进程的唯一标识符(PID) │├──tgid:threadgroupID,线程组ID │└──comm:进程的可读名称 ├──ProcessStateManagement │├──state:当前进程的状态(TASK_RUNNING,TASK_INTERRUPTIBLE等) ...
structtask_struct*group_leader;//这个是该进程所有线程的链表。structlist_head thread_group;//顾名思义,这个是该进程使用cpu时间的信息,utime是在用户态下执行的时间,stime是在内核态下执行的时间。cputime_tutime,stime;//下面的是启动的时间,只是时间基准不一样。structtimespec start_time;structtimespec ...
// include\linux\sched.hpid_tpid;pid_ttgid;structtask_struct*group_leader; pid(process ID)是任务的唯一标识符,每一个任务的 pid 都是不一样的。也就是说,如果一个进程有多个线程,那么这些多个线程所使用的 pid 也都是不一样的。 tgid(thread group ID),是线程组的 ID,一个进程中的所有线程的 tgid...