I have a homework where I must add some entries to the task_struct and do some things with them. Also, I must initialize an entry to a specific int when the task_struct initialize.
Where is the file/code that task_struct does its first initialization?
I found INIT_TASK.h but there is the first process of the task_struct table. I want to find where each task_struct initializes and defines it's starting values in order to define some numbers to the new entries I inserted.
I tried fork, do_fork, init_task but I could not find something except init_task.h as I said in my first post. Could you please just tell me either the syscall either the file that I can find the code for task_struct initialization?
You were already on the right track. Now do_fork() as well as the function behind the SYSCALL_DEFINE0(fork) calls _do_fork(), which calls copy_process(), where the new struct task_struct *p is created by p = dup_task_struct(current, node); - thereafter, copy_process() would be a good place for your additions. All this is in the file kernel/fork.c.
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