Results 1 to 1 of 1
Hi, I'm new to linux kernel programming, and I have basic question about new processes creation in linux. It's actually for an assignment I'm doing for an OS course, so ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-28-2011 #1
- Join Date
- Mar 2011
How are new processes created?
I'm new to linux kernel programming, and I have basic question about new processes creation in linux.
It's actually for an assignment I'm doing for an OS course, so here's in general what I'm supposed to do:
Each process will have a new field, called 'tag' (non-negative integer) - added a new 'tag' field to task_struct.
The first process created will have it's tag initialized to 0 - added the initialization to init_idle(), which creates the first process.
Every other process will have it's tag initialized to half the tag of it's parent.
Now, as part of the assignment, I've also added several functions to edit these tags, and here's what I get:
After running one of these functions, the 'init' process had it's tag set to 4. After this, I open the Terminal and run "ps -AH", which shows:
So ps lists 'init' as 'gnome-terminal's' parent in the task hierarchy, but it didn't get half 'init''s tag (which should be 2).
I've implemented this tag initialization for new processes using the following statement in the do_fork() function in fork.c:
p->tag /= 2;
right after the place where the current process' task_struct is copied to the new process' task_struct, i.e.:
*p = *current;
Also, I've tested this using fork() in my code, and the child process did get the (parent's tag)/2.
In class, we were taught that every process is created using fork() as a child of another process, which in this case should be 'init' as listed by 'ps'. If so, why doesn't the tag initialization work, and if not, then what's really going on here?
Thanks in advance for any help.