20233808《Linux内核原理分析与设计》第七周作业

1.教材学习及与chatgpt的对话

https://chat.openai.com/share/9199ce74-bef5-4e82-b301-3f44a6d07e2b

2.实验楼

task_struct结构

task_struct用于表示每个进程或线程的状态和相关信息。它包含了大量的字段,用于跟踪和管理进程的各种属性,如进程ID、父进程ID、调度信息、信号处理、资源限制、文件描述符表、内存管理信息等等。

struct task_struct {
	volatile long state;	/*表示进程的当前状态,可能是未运行-1可运行0或已停止(>0)*/
	void *stack;
	atomic_t usage;  /* usage:一个原子计数器,用于跟踪进程的使用计数 */
	unsigned int flags;	/* 存储与进程相关的标志,这些标志可以包括进程的特定属性或状态信息 */
	unsigned int ptrace; /*与进程跟踪相关的字段,用于跟踪进程的父进程或调试器*/

#ifdef CONFIG_SMP
	struct llist_node wake_entry;
	int on_cpu; /*在多处理器系统(SMP)中,表示进程当前正在哪个CPU上运行*/
	struct task_struct *last_wakee;
	unsigned long wakee_flips;
	unsigned long wakee_flip_decay_ts;

	int wake_cpu;
#endif
	int on_rq;

	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_CGROUP_SCHED
	struct task_group *sched_task_group;
#endif
	struct sched_dl_entity dl;
/*se、rt、dl:与调度相关的实体,包括普通、实时和截止(deadline)调度的信息*?
#ifdef CONFIG_PREEMPT_NOTIFIERS
	/*struct preempt_notifier的列表: */
	struct hlist_head preempt_notifiers;
#endif

#ifdef CONFIG_BLK_DEV_IO_TRACE
	unsigned int btrace_seq;
#endif

	unsigned int policy;
/*调度策略,表示进程使用的调度策略,例如普通(SCHED_NORMAL)、先进先出(SCHED_FIFO)等。*/
	int nr_cpus_allowed;
	cpumask_t cpus_allowed;

#ifdef CONFIG_PREEMPT_RCU
	int rcu_read_lock_nesting;
	union rcu_special 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_TASKS_RCU
	unsigned long rcu_tasks_nvcsw;
	bool rcu_tasks_holdout;
	struct list_head rcu_tasks_holdout_list;
	int rcu_tasks_idle_cpu;
#endif /* #ifdef CONFIG_TASKS_RCU */

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

	struct list_head tasks;
#ifdef CONFIG_SMP
	struct plist_node pushable_tasks;
	struct rb_node pushable_dl_tasks;
#endif

	struct mm_struct *mm, *active_mm;
/*mm、active_mm:内存管理相关的字段,包括进程的内存描述符。mm指向当前进程的内存描述符,active_mm指向进程上下文切换时的备用内存描述符*/
#ifdef CONFIG_COMPAT_BRK
	unsigned brk_randomized:1;
#endif
	/* 每个线程的VMA缓存*/
	u32 vmacache_seqnum;
	struct vm_area_struct *vmacache[VMACACHE_SIZE];
#if defined(SPLIT_RSS_COUNTING)
	struct task_rss_stat	rss_stat;
#endif
/* 任务状态 */
	int exit_state;
	int exit_code, exit_signal;
	int pdeath_signal;  /*  当父进程死亡时发送的信号 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值