Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding entry to task_struct and initializing to default value

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".

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

like image 866
David Avatar asked Nov 08 '11 00:11

David


1 Answers

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

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.

like image 72
Dan Aloni Avatar answered Sep 26 '22 15:09

Dan Aloni