Linux 2.6.36版本内核分析之task_struct

这篇博客详细分析了Linux 2.6.36版本内核中的task_struct结构,涵盖了其在进程管理、调度、内存分配、信号处理等方面的关键字段,揭示了Linux内核如何高效管理进程。
摘要由CSDN通过智能技术生成

struct task_struct {
 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
 void *stack;
 atomic_t usage;
 unsigned int flags; /* per process flags, defined below */
 unsigned int ptrace;

 int lock_depth;  /* BKL lock depth */

#ifdef CONFIG_SMP
#ifdef __ARCH_WANT_UNLOCKED_CTXSW
 int oncpu;
#endif
#endif

 int prio, static_prio, normal_prio;
 unsigned int rt_priority;
 const struct sched_class *sched_class;
 struct sched_entity se;
 struct sched_rt_entity rt;

#ifdef CONFIG_PREEMPT_NOTIFIERS
 /* list of struct preempt_notifier: */
 struct hlist_head preempt_notifiers;
#endif

 /*
  * fpu_counter contains the number of consecutive context switches
  * that the FPU is used. If this is over a threshold, the lazy fpu
  * saving becomes unlazy to save the trap. This is an unsigned char
  * so that after 256 times the counter wraps and the behavior turns
  * lazy again; this to deal with bursty apps that only use FPU for
  * a short time
  */
 unsigned char fpu_counter;
#ifdef CONFIG_BLK_DEV_IO_TRACE
 unsigned int btrace_seq;
#endif

 unsigned int policy;
 cpumask_t cpus_allowed;

#ifdef CONFIG_TREE_PREEMPT_RCU
 int rcu_read_lock_nesting;
 char rcu_read_unlock_special;
 struct rcu_node *rcu_blocked_node;
 struct list_head rcu_node_entry;
#endif /* #ifdef CONFIG_TREE_PREEMPT_RCU */

#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
 struct sched_info sched_info;
#endif

 struct list_head tasks;
 struct plist_node pushable_tasks;

 struct mm_struct *mm, *active_mm;
#if defined(SPLIT_RSS_COUNTING)
 struct task_rss_stat rss_stat;
#endif
/* task state */
 int exit_state;
 int exit_code, exit_signal;
 int pdeath_signal;  /*  The signal sent when the parent dies  */
 /* ??? */
 unsigned int personality;
 unsigned did_exec:1;
 unsigned in_execve:1; /* Tell the LSMs that the process is doing an
     * execve */
 unsigned in_iowait:1;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值