进程是处于执行期的程序以及它所管理的资源(如打开的文件、挂起的信号、进程状态、地址空间等等)的总称。注意,程序并不是进程,实际上两个或多个进程不仅有可能执行同一程序,而且还有可能共享地址空间等资源。
linux内核通过一个被称为进程描述符的task_struct结构体来管理进程,这个结构体包含了一个进程所需的所有信息。它定义在include/linux/sched.h文件中。
谈到task_struct结构体,可以说她是linux内核源码中最复杂的一个结构体了,成员之多,占用内存之大。
鉴于她的复杂,我们不能简单的亵渎,而是要深入“窥探”.
下面来慢慢介绍这些复杂成员
进程状态 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
state成员的可能取值如下
/*
* task state bitmask. note! these bits are also
* encoded in fs/proc/array.c: get_task_state().
*
* we have two separate sets of flags: task->state
* is about runnability, while task->exit_state are
* about the task exiting. confusing, but this way
* modifying one set can't modify the other one by
* mistake.
*/
#define task_running 0
#define task_interruptible 1
#define task_uninterruptible 2
#define __task_stopped 4
#define __task_traced 8
/* in tsk->exit_state */
#define exit_dead 16
#define exit_zombie 32
#define exit_trace (exit_zombie | exit_dead)
/* in tsk->state again */
#define task_dead 64
#define task_wakekill 128 /** wake on signals that are deadly **/
#define task_waking 256
#define task_parked 512
#define task_noload 1024
#define task_state_max 2048
/* convenience macros for the sake of set_task_state */
#define task_killable (task_wakekill | task_uninterruptible)
#define task_stopped (task_wakekill | __task_stopped)
#define task_traced (task_wakekill | __task_traced)
5个互斥状态 state域能够取5个互为排斥的值(通俗一点就是这五个值任意两个不能一起使用,只能单独使用)。系统中的每个进程都必然处于以上所列进程状态中的一种。
2个终止状态 其实还有两个附加的进程状态既可以被添加到state域中,又可以被添加到exit_state域中。只有当进程终止的时候,才会达到这两种状态.
/* task state */
int exit_state;
int exit_code, exit_signal;
新增睡眠状态 进程状态 task_uninterruptible 和 task_interruptible 都是睡眠状态。现在,我们来看看内核如何将进程置为睡眠状态。
内核如何将进程置为睡眠状态 linux 内核提供了两种方法将进程置为睡眠状态。
将进程置为睡眠状态的普通方法是将进程状态设置为 task_interruptible 或 task_uninterruptible 并调用调度程序的 schedule() 函数。这样会将进程从 cpu 运行队列中移除。
如果进程处于可中断模式的睡眠状态(通过将其状态设置为 task_interruptible),那么可以通过显式的唤醒呼叫(wakeup_process())或需要处理的信号来唤醒它。
但是,如果进程处于非可中断模式的睡眠状态(通过将其状态设置为 task_uninterruptible),那么只能通过显式的唤醒呼叫将其唤醒。除非万不得已,否则我们建议您将进程置为可中断睡眠模式,而不是不可中断睡眠模式(比如说在设备 i/o 期间,处理信号非常困难时)。
当处于可中断睡眠模式的任务接收到信号时,它需要处理该信号(除非它已被屏弊),离开之前正在处理的任务(此处需要清除代码),并将 -eintr 返回给用户空间。再一次,检查这些返回代码和采取适当操作的工作将由程序员完成。
因此,懒惰的程序员可能比较喜欢将进程置为不可中断模式的睡眠状态,因为信号不会唤醒这类任务。
但需要注意的一种情况是,对不可中断睡眠模式的进程的唤醒呼叫可能会由于某些原因不会发生,这会使进程无法被终止,从而最终引发问题,因为惟一的解决方法就是重启系统。一方面,您需要考虑一些细节,因为不这样做会在内核端和用户端引入 bug。另一方面,您可能会生成永远不会停止的进程(被阻塞且无法终止的进程)。
现在,我们在内核中实现了一种新的睡眠方法
linux kernel 2.6.25 引入了一种新的进程睡眠状态
它定义如下:
#define task_wakekill 128 /** wake on signals that are deadly **/
/* convenience macros for the sake of set_task_state */
#define task_killable (task_wakekill | task_uninterruptible)
#define task_stopped (task_wakekill | __task_stopped)
#define task_traced (task_wakekill | __task_traced)
换句话说,task_uninterruptible + task_wakekill = task_killable。
而task_wakekill 用于在接收到致命信号时唤醒进程
新的睡眠状态允许 task_uninterruptible 响应致命信号
进程状态的切换过程和原因大致如下图
进程标识符(pid) pid_t pid;
pid_t tgid;
unix系统通过pid来标识进程,linux把不同的pid与系统中每个进程或轻量级线程关联,而unix程序员希望同一组线程具有共同的pid,遵照这个标准linux引入线程组的概念。一个线程组所有线程与领头线程具有相同的pid,存入tgid字段,getpid()返回当前进程的tgid值而不是pid的值。
在config_base_small配置为0的情况下,pid的取值范围是0到32767,即系统中的进程数最大为32768个。
#define pid_max_default (config_base_small ? 0x1000 : 0x8000)
在linux系统中,一个线程组中的所有线程使用和该线程组的领头线程(该组中的第一个轻量级进程)相同的pid,并被存放在tgid成员中。只有线程组的领头线程的pid成员才会被设置为与tgid相同的值。注意,getpid()系统调用返回的是当前进程的tgid值而不是pid值。
进程内核栈 void *stack;
内核栈与线程描述符
对每个进程,linux内核都把两个不同的数据结构紧凑的存放在一个单独为进程分配的内存区域中
一个是内核态的进程堆栈,
另一个是紧挨着进程描述符的小数据结构thread_info,叫做线程描述符。
linux把thread_info(线程描述符)和内核态的线程堆栈存放在一起,这块区域通常是8192k(占两个页框),其实地址必须是8192的整数倍。
在
linux/arch/x86/include/asm/page_32_types.h中,
#define thread_size_order 1
#define thread_size (page_size
在这个图中,esp寄存器是cpu栈指针,用来存放栈顶单元的地址。在80x86系统中,栈起始于顶端,并朝着这个内存区开始的方向增长。从用户态刚切换到内核态以后,进程的内核栈总是空的。因此,esp寄存器指向这个栈的顶端。一旦数据写入堆栈,esp的值就递减。
内核栈数据结构描述thread_info和thread_union thread_info是体系结构相关的,结构的定义在thread_info.h中
linux内核中使用一个联合体来表示一个进程的线程描述符和内核栈:
union thread_union
{
struct thread_info thread_info;
unsigned long stack[thread_size/sizeof(long)];
};
获取当前在cpu上正在运行进程的thread_info
下面来说说如何通过esp栈指针来获取当前在cpu上正在运行进程的thread_info结构。
实际上,上面提到,thread_info结构和内核态堆栈是紧密结合在一起的,占据两个页框的物理内存空间。而且,这两个页框的起始起始地址是213对齐的。
早期的版本中,不需要对64位处理器的支持,所以,内核通过简单的屏蔽掉esp的低13位有效位就可以获得thread_info结构的基地址了。
我们在下面对比了,获取正在运行的进程的thread_info的实现方式
早期版本
当前的栈指针(current_stack_pointer == sp)就是esp,
thread_size为8k,二进制的表示为0000 0000 0000 0000 0010 0000 0000 0000。
~(thread_size-1)的结果刚好为1111 1111 1111 1111 1110 0000 0000 0000,第十三位是全为零,也就是刚好屏蔽了esp的低十三位,最终得到的是thread_info的地址。
进程最常用的是进程描述符结构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_info()->task)
#define current get_current()
这个定义是体系结构无关的,当然linux也为各个体系结构定义了更加方便或者快速的current
分配和销毁thread_info 进程通过alloc_thread_info_node函数分配它的内核栈,通过free_thread_info函数释放所分配的内核栈。
# if thread_size >= page_size
static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
int node)
{
struct page *page = alloc_kmem_pages_node(node, threadinfo_gfp,
thread_size_order);
return page ? page_address(page) : null;
}
static inline void free_thread_info(struct thread_info *ti)
{
free_kmem_pages((unsigned long)ti, thread_size_order);
}
# else
static struct kmem_cache *thread_info_cache;
static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
int node)
{
return kmem_cache_alloc_node(thread_info_cache, threadinfo_gfp, node);
}
static void free_thread_info(struct thread_info *ti)
{
kmem_cache_free(thread_info_cache, ti);
}
其中,thread_size_order宏的定义请查看
进程标记 unsigned int flags; /* per process flags, defined below */
反应进程状态的信息,但不是运行状态,用于内核识别进程当前的状态,以备下一步操作
flags成员的可能取值如下,这些宏以pf(processflag)开头
例如
pf_forknoexec 进程刚创建,但还没执行。
pf_superpriv 超级用户特权。
pf_dumpcore dumped core。
pf_signaled 进程被信号(signal)杀出。
pf_exiting 进程开始关闭。
/*
* per process flags
*/
#define pf_exiting 0x00000004 /* getting shut down */
#define pf_exitpidone 0x00000008 /* pi exit done on shut down */
#define pf_vcpu 0x00000010 /* i'm a virtual cpu */
#define pf_wq_worker 0x00000020 /* i'm a workqueue worker */
#define pf_forknoexec 0x00000040 /* forked but didn't exec */
#define pf_mce_process 0x00000080 /* process policy on mce errors */
#define pf_superpriv 0x00000100 /* used super-user privileges */
#define pf_dumpcore 0x00000200 /* dumped core */
#define pf_signaled 0x00000400 /* killed by a signal */
#define pf_memalloc 0x00000800 /* allocating memory */
#define pf_nproc_exceeded 0x00001000 /* set_user noticed that rlimit_nproc was exceeded */
#define pf_used_math 0x00002000 /* if unset the fpu must be initialized before use */
#define pf_used_async 0x00004000 /* used async_schedule*(), used by module init */
#define pf_nofreeze 0x00008000 /* this thread should not be frozen */
#define pf_frozen 0x00010000 /* frozen for system suspend */
#define pf_fstrans 0x00020000 /* inside a filesystem transaction */
#define pf_kswapd 0x00040000 /* i am kswapd */
#define pf_memalloc_noio 0x00080000 /* allocating memory without io involved */
#define pf_less_throttle 0x00100000 /* throttle me less: i clean memory */
#define pf_kthread 0x00200000 /* i am a kernel thread */
#define pf_randomize 0x00400000 /* randomize virtual address space */
#define pf_swapwrite 0x00800000 /* allowed to write to swap */
#define pf_no_setaffinity 0x04000000 /* userland is not allowed to meddle with cpus_allowed */
#define pf_mce_early 0x08000000 /* early kill for mce process policy */
#define pf_mutex_tester 0x20000000 /* thread belongs to the rt mutex tester */
#define pf_freezer_skip 0x40000000 /* freezer should not count it as freezable */
#define pf_suspend_task 0x80000000 /* this thread called freeze_processes and should not be frozen */
表示进程亲属关系的成员
/*
* pointers to (original) parent process, youngest child, younger sibling,
* older sibling, respectively. (p->father can be replaced with
* p->real_parent->pid)
*/
struct task_struct __rcu *real_parent; /* real parent process */
struct task_struct __rcu *parent; /* recipient of sigchld, wait4() reports */
/*
* children/sibling forms the list of my natural children
*/
struct list_head children; /* list of my children */
struct list_head sibling; /* linkage in my parent's children list */
struct task_struct *group_leader; /* threadgroup leader */
在linux系统中,所有进程之间都有着直接或间接地联系,每个进程都有其父进程,也可能有零个或多个子进程。拥有同一父进程的所有进程具有兄弟关系。
ptrace系统调用 ptrace 提供了一种父进程可以控制子进程运行,并可以检查和改变它的核心image。
它主要用于实现断点调试。一个被跟踪的进程运行中,直到发生一个信号。则进程被中止,并且通知其父进程。在进程中止的状态下,进程的内存空间可以被读写。父进程还可以使子进程继续执行,并选择是否是否忽略引起中止的信号。
unsigned int ptrace;
ptraced is the list of tasks this task is using ptrace on.
* this includes both natural children and ptrace_attach targets.
* p->ptrace_entry is p's link on the p->parent->ptraced list.
*/
struct list_head ptraced;
struct list_head ptrace_entry;
unsigned long ptrace_message;
siginfo_t *last_siginfo; /* for ptrace use. */
成员ptrace被设置为0时表示不需要被跟踪,它的可能取值如下:
/*
* ptrace flags
*
* the owner ship rules for task->ptrace which holds the ptrace
* flags is simple. when a task is running it owns it's task->ptrace
* flags. when the a task is stopped the ptracer owns task->ptrace.
*/
#define pt_seized 0x00010000 /* seize used, enable new behavior */
#define pt_ptraced 0x00000001
#define pt_dtrace 0x00000002 /* delayed trace (used on m68k, i386) */
#define pt_ptrace_cap 0x00000004 /* ptracer can follow suid-exec */
#define pt_opt_flag_shift 3
/* pt_trace_* event enable flags */
#define pt_event_flag(event) (1 << (pt_opt_flag_shift + (event)))
#define pt_tracesysgood pt_event_flag(0)
#define pt_trace_fork pt_event_flag(ptrace_event_fork)
#define pt_trace_vfork pt_event_flag(ptrace_event_vfork)
#define pt_trace_clone pt_event_flag(ptrace_event_clone)
#define pt_trace_exec pt_event_flag(ptrace_event_exec)
#define pt_trace_vfork_done pt_event_flag(ptrace_event_vfork_done)
#define pt_trace_exit pt_event_flag(ptrace_event_exit)
#define pt_trace_seccomp pt_event_flag(ptrace_event_seccomp)
#define pt_exitkill (ptrace_o_exitkill << pt_opt_flag_shift)
#define pt_suspend_seccomp (ptrace_o_suspend_seccomp << pt_opt_flag_shift)
/* single stepping state bits (used on arm and pa-risc) */
#define pt_singlestep_bit 31
#define pt_singlestep (1< #define pt_blockstep_bit 30
#define pt_blockstep (1< realtime > fair > idletask
开发者可以根据己的设计需求,來把所属的task配置到不同的scheduling class中.
进程地址空间 /* http://lxr.free-electrons.com/source/include/linux/sched.h?v=4.5#l1453 */
struct mm_struct *mm, *active_mm;
/* per-thread vma caching */
u32 vmacache_seqnum;
struct vm_area_struct *vmacache[vmacache_size];
#if defined(split_rss_counting)
struct task_rss_stat rss_stat;
#endif
/* http://lxr.free-electrons.com/source/include/linux/sched.h?v=4.5#l1484 */
#ifdef config_compat_brk
unsigned brk_randomized:1;
#endif
因此如果当前内核线程被调度之前运行的也是另外一个内核线程时候,那么其mm和avtive_mm都是null
判断标志 int exit_code, exit_signal;
int pdeath_signal; /* the signal sent when the parent dies */
unsigned long jobctl; /* jobctl_*, siglock protected */
/* used for emulating abi behavior of previous linux versions */
unsigned int personality;
/* scheduler bits, serialized by scheduler locks */
unsigned sched_reset_on_fork:1;
unsigned sched_contributes_to_load:1;
unsigned sched_migrated:1;
unsigned :0; /* force alignment to the next boundary */
/* unserialized, strictly 'current' */
unsigned in_execve:1; /* bit to tell lsms we're in execve */
unsigned in_iowait:1;
时间 cputime_t utime, stime, utimescaled, stimescaled;
cputime_t gtime;
struct prev_cputime prev_cputime;
#ifdef config_virt_cpu_accounting_gen
seqcount_t vtime_seqcount;
unsigned long long vtime_snap;
enum {
/* task is sleeping or running in a cpu with vtime inactive */
vtime_inactive = 0,
/* task runs in userspace in a cpu with vtime active */
vtime_user,
/* task runs in kernelspace in a cpu with vtime active */
vtime_sys,
} vtime_snap_whence;
#endif
unsigned long nvcsw, nivcsw; /* context switch counts */
u64 start_time; /* monotonic time in nsec */
u64 real_start_time; /* boot based time in nsec */
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
unsigned long min_flt, maj_flt;
struct task_cputime cputime_expires;
struct list_head cpu_timers[3];
/* process credentials */
const struct cred __rcu *real_cred; /* objective and real subjective task
* credentials (cow) */
const struct cred __rcu *cred; /* effective (overridable) subjective task
* credentials (cow) */
char comm[task_comm_len]; /* executable name excluding path
- access with [gs]et_task_comm (which lock
it with task_lock())
- initialized normally by setup_new_exec */
/* file system info */
struct nameidata *nameidata;
#ifdef config_sysvipc
/* ipc stuff */
struct sysv_sem sysvsem;
struct sysv_shm sysvshm;
#endif
#ifdef config_detect_hung_task
/* hung task detection */
unsigned long last_switch_count;
#endif
信号处理 /* signal handlers */
struct signal_struct *signal;
struct sighand_struct *sighand;
1583
sigset_t blocked, real_blocked;
sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */
struct sigpending pending;
1587
unsigned long sas_ss_sp;
size_t sas_ss_size;
其他 (1)、用于保护资源分配或释放的自旋锁
/* protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
* mempolicy */
spinlock_t alloc_lock;
(2)、进程描述符使用计数,被置为2时,表示进程描述符正在被使用而且其相应的进程处于活动状态
atomic_t usage;
(3)、用于表示获取大内核锁的次数,如果进程未获得过锁,则置为-1。
int lock_depth; /* bkl lock depth */
(4)、在smp上帮助实现无加锁的进程切换(unlocked context switches)
#ifdef config_smp
#ifdef __arch_want_unlocked_ctxsw
int oncpu;
#endif
#endif
(5)、preempt_notifier结构体链表
#ifdef config_preempt_notifiers
/* list of struct preempt_notifier: */
struct hlist_head preempt_notifiers;
#endif
(6)、fpu使用计数
unsigned char fpu_counter;
(7)、 blktrace是一个针对linux内核中块设备i/o层的跟踪工具。
#ifdef config_blk_dev_io_trace
unsigned int btrace_seq;
#endif
(8)、rcu同步原语
#ifdef config_preempt_rcu
int rcu_read_lock_nesting;
char rcu_read_unlock_special;
struct list_head rcu_node_entry;
#endif /* #ifdef config_preempt_rcu */
#ifdef config_tree_preempt_rcu
struct rcu_node *rcu_blocked_node;
#endif /* #ifdef config_tree_preempt_rcu */
#ifdef config_rcu_boost
struct rt_mutex *rcu_boost_mutex;
#endif /* #ifdef config_rcu_boost */
(9)、用于调度器统计进程的运行信息
#if defined(config_schedstats) || defined(config_task_delay_acct)
struct sched_info sched_info;
#endif
(10)、用于构建进程链表
struct list_head tasks;
(11)、to limit pushing to one attempt
#ifdef config_smp
struct plist_node pushable_tasks;
#endif
(12)、防止内核堆栈溢出
#ifdef config_cc_stackprotector
/* canary value for the -fstack-protector gcc feature */
unsigned long stack_canary;
#endif
在gcc编译内核时,需要加上-fstack-protector选项。
(13)、pid散列表和链表
/* pid/pid hash table linkage. */
struct pid_link pids[pidtype_max];
struct list_head thread_group; //线程组中所有进程的链表
(14)、do_fork函数
struct completion *vfork_done; /* for vfork() */
int __user *set_child_tid; /* clone_child_settid */
int __user *clear_child_tid; /* clone_child_cleartid */
在执行do_fork()时,如果给定特别标志,则vfork_done会指向一个特殊地址。
如果copy_process函数的clone_flags参数的值被置为clone_child_settid或clone_child_cleartid,则会把child_tidptr参数的值分别复制到set_child_tid和clear_child_tid成员。这些标志说明必须改变子进程用户态地址空间的child_tidptr所指向的变量的值。
(15)、缺页统计
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
unsigned long min_flt, maj_flt;
(16)、进程权能
const struct cred __rcu *real_cred; /* objective and real subjective task
* credentials (cow) */
const struct cred __rcu *cred; /* effective (overridable) subjective task
* credentials (cow) */
struct cred *replacement_session_keyring; /* for keyctl_session_to_parent */
(17)、相应的程序名
char comm[task_comm_len];
(18)、文件
/* file system info */
int link_count, total_link_count;
/* filesystem information */
struct fs_struct *fs;
/* open file information */
struct files_struct *files;
fs用来表示进程与文件系统的联系,包括当前目录和根目录。
files表示进程当前打开的文件。
(19)、进程通信(sysvipc)
#ifdef config_sysvipc
/* ipc stuff */
struct sysv_sem sysvsem;
#endif
(20)、处理器特有数据
/* cpu-specific state of this task */
struct thread_struct thread;
(21)、命名空间
/* namespaces */
struct nsproxy *nsproxy;
(22)、进程审计
struct audit_context *audit_context;
#ifdef config_auditsyscall
uid_t loginuid;
unsigned int sessionid;
#endif
(23)、secure computing
seccomp_t seccomp;
(24)、用于copy_process函数使用clone_parent 标记时
/* thread group tracking */
u32 parent_exec_id;
u32 self_exec_id;
(25)、中断
#ifdef config_generic_hardirqs
/* irq handler threads */
struct irqaction *irqaction;
#endif
#ifdef config_trace_irqflags
unsigned int irq_events;
unsigned long hardirq_enable_ip;
unsigned long hardirq_disable_ip;
unsigned int hardirq_enable_event;
unsigned int hardirq_disable_event;
int hardirqs_enabled;
int hardirq_context;
unsigned long softirq_disable_ip;
unsigned long softirq_enable_ip;
unsigned int softirq_disable_event;
unsigned int softirq_enable_event;
int softirqs_enabled;
int softirq_context;
#endif
(26)、task_rq_lock函数所使用的锁
/* protection of the pi data structures: */
raw_spinlock_t pi_lock;
(27)、基于pi协议的等待互斥锁,其中pi指的是priority inheritance(优先级继承)
#ifdef config_rt_mutexes
/* pi waiters blocked on a rt_mutex held by this task */
struct plist_head pi_waiters;
/* deadlock detection and priority inheritance handling */
struct rt_mutex_waiter *pi_blocked_on;
#endif
(28)、死锁检测
#ifdef config_debug_mutexes
/* mutex deadlock detection */
struct mutex_waiter *blocked_on;
#endif
(29)、jfs文件系统
/* journalling filesystem info */
void *journal_info;
(30)、块设备链表
/* stacked block device info */
struct bio_list *bio_list;
(31)、内存回收
struct reclaim_state *reclaim_state;
(32)、存放块设备i/o数据流量信息
struct backing_dev_info *backing_dev_info;
(33)、i/o调度器所使用的信息
struct io_context *io_context;
(34)、记录进程的i/o计数
struct task_io_accounting ioac;
if defined(config_task_xacct)
u64 acct_rss_mem1; /* accumulated rss usage */
u64 acct_vm_mem1; /* accumulated virtual memory usage */
cputime_t acct_timexpd; /* stime + utime since last update */
endif
在ubuntu 11.04上,执行cat获得进程1的i/o计数如下:
输出的数据项刚好是task_io_accounting结构体的所有成员。
(35)、cpuset功能
#ifdef config_cpusets
nodemask_t mems_allowed; /* protected by alloc_lock */
int mems_allowed_change_disable;
int cpuset_mem_spread_rotor;
int cpuset_slab_spread_rotor;
#endif
(36)、control groups
#ifdef config_cgroups
/* control group info protected by css_set_lock */
struct css_set __rcu *cgroups;
/* cg_list protected by css_set_lock and tsk->alloc_lock */
struct list_head cg_list;
#endif
#ifdef config_cgroup_mem_res_ctlr /* memcg uses this to do batch job */
struct memcg_batch_info {
int do_batch; /* incremented when batch uncharge started */
struct mem_cgroup *memcg; /* target memcg of uncharge */
unsigned long bytes; /* uncharged usage */
unsigned long memsw_bytes; /* uncharged mem+swap usage */
} memcg_batch;
#endif
(37)、futex同步机制
#ifdef config_futex
struct robust_list_head __user *robust_list;
#ifdef config_compat
struct compat_robust_list_head __user *compat_robust_list;
#endif
struct list_head pi_state_list;
struct futex_pi_state *pi_state_cache;
#endif
(38)、非一致内存访问(numa non-uniform memory access)
#ifdef config_numa
struct mempolicy *mempolicy; /* protected by alloc_lock */
short il_next;
#endif
(39)、文件系统互斥资源
atomic_t fs_excl; /* holding fs exclusive resources */
(40)、rcu链表
struct rcu_head rcu;
(41)、管道
struct pipe_inode_info *splice_pipe;
(42)、延迟计数
#ifdef config_task_delay_acct
struct task_delay_info *delays;
#endif
(43)、fault injection
#ifdef config_fault_injection
int make_it_fail;
#endif
(44)、floating proportions
struct prop_local_single dirties;
(45)、infrastructure for displayinglatency
#ifdef config_latencytop
int latency_record_count;
struct latency_record latency_record[lt_savecount];
#endif
(46)、time slack values,常用于poll和select函数
unsigned long timer_slack_ns;
unsigned long default_timer_slack_ns;
(48)、socket控制消息(control message)
struct list_head *scm_work_list;
(47)、ftrace跟踪器
#ifdef config_function_graph_tracer
/* index of current stored address in ret_stack */
int curr_ret_stack;
/* stack of return addresses for return function tracing */
struct ftrace_ret_stack *ret_stack;
/* time stamp for last schedule */
unsigned long long ftrace_timestamp;
/*
* number of functions that haven't been traced
* because of depth overrun.
*/
atomic_t trace_overrun;
/* pause for the tracing */
atomic_t tracing_graph_pause;
#endif
#ifdef config_tracing
/* state flags for use by tracers */
unsigned long trace;
/* bitmask of trace recursion */
unsigned long trace_recursion;
#endif /* config_tracing */
原文标题:linux进程描述符task_struct结构体详解
文章出处:【微信公众号:一口linux】欢迎添加关注!文章转载请注明出处。
如何配置设置建立dhcp服务器
5GNR小区带宽60M改100M配置指导书
OCH2B使用了豪威集团的AntLinx专有技术
铠侠领先推出面向企业与数据中心的CD8P系列PCIe 5.0 SSD
威迈斯IPO上市观察 深度研发赋能 成功解决行业难点
linux内核源码中的task_struct结构体
华为启动突围Plan B,鸿蒙系统装上车
基于CPCI总线结构的微波接收机设计
详解电容器的原理与结构,你都会吗?
兆芯携手火星高科 推出多款存储及服务器产品
LED驱动电源过CE认证要求解析
李楠:iPhone摄像顶级优势远胜于安卓,拍视频可选iPhone 12 Pro Max
看清这六大芯片商都有哪些“野心”
网络威胁识别新工具 协助分析自驾车潜在弱点
各频段发射管参数大全
RGB-D图像是什么
富士通的非易失性铁电存储器FRAM有着广泛的应用
传三星s8明年3月发布 无边框全屏幕设计+取消物理Home键
变频器接电位器怎么接_变频器电位器接线图_变频器外接电位器接法
CAMCOPTER S-100无人机提供欧洲海上监视