tzegian
tzegian

Reputation: 587

Linux kernel, where is the task_struct (process) initialization

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.

Upvotes: 4

Views: 3461

Answers (1)

Armali
Armali

Reputation: 19375

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.

Upvotes: 2

Related Questions