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
?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With