将条目添加到task_struct并初始化为默认值 [英] Adding entry to task_struct and initializing to default value

查看:110
本文介绍了将条目添加到task_struct并初始化为默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向过程控制块结构(task_struct)添加一个条目.让我们说一种标记某些过程的方法.我想将除某些特殊进程"之外的所有进程的该字段初始化为0,稍后通过调用sched_setscheduler(),我将为特殊进程"设置此标志.

I want to add an entry to process control block structure (task_struct). Let say a way to tag some process. I want to initialize this field to 0 for all the process except "some special processes", later by calling sched_setscheduler() I will set this flag for the "special processes".

有人知道如何为task_struct中的成员变量分配默认值吗?

Does anybody have an idea how to assign a default value to a member variable in task_struct?

推荐答案

我假设您正在谈论的是最新的Linux内核,因为实现细节会随时间而变化.

I'm assuming you are talking about a recent Linux kernel, because implementation detail changes over time.

有两个选项.第一个-您可以在init_task全局变量中设置变量的值.在linux/init_task.h标头中查看如何完成.第二种选择是将代码添加到copy_process中,您可能仍要执行此操作,以便正确处理要添加的字段的fork()继承.

There are two options. The first - you can set the value of the variable in the init_task global. See how it is done in the linux/init_task.h header. The second option is to add code to copy_process, which you might want to do anyway in order to properly handle the fork() inheritance of the field you are adding.

这篇关于将条目添加到task_struct并初始化为默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆