Is anyone familiar with os/161 and can answer a few questions for me?
How exactly does child pid, parent pid works.
I know that when you call thread_fork()
you are creating another thread base on the current thread, the new thread should have a unique id for himself and a different file descriptor table. While sys_fork
create a child from curthread
, the child is the same as the parent besides the pid. But I am confused in how pid and parent pid works.
This is my interpretation of the process table. There is only one process table for the whole system. For now I have parent_pid
and my_pid
for every thread.
-A parent thread can have multiple child, (by keep calling sys_fork
).
-A child can only have one parent.
-Whenever sys_fork
is called, a child is created and the parent_pid
for this child is set to the pid of the thread who created this child.
-pid of 1 is for the boot/menu thread.
Am I even on the right track in understanding how process table works?
One last question:
For sys_waitpid()
: Only parent can use waitpid
? and they can only wait on their childs? Can a child use waitpid
on a parent (or would this result in deadlock)?
I been searching around with Google, but I find so many contradictions, up till now I still can't find a clear answer to my questions.