As I understand it, process descriptors are stored in a doubly linked list data structure. But a fork can create multiple children for the same process, so that makes me think that there is a tree structure, because multiple processes will point to one parent process. Which is correct? Are process descriptors different from processes?
Your confusion stems from mixing two things: (1) keeping the process descriptors organized, and (2) the parent/child relationship. You don't need the parent/child relationship to decide which process to run next, or (in general) which process to deliver a signal to. So, the Linux
You're correct, a tree struct exists for the child/parent relationship, but it seems to be concealed in another list, and a pointer to the parent. The famed doubly-linked list isn't obvious in the 3.11.5 |
|||||
|
This of course creates a rather natural parent-children relation between processes, yet this is independent of the internal representation in the kernel. Process descriptors can be implemented as a linked list, tree, hash table or any other (more or less) suitable structure. All that one really needs is place in the kernel process descriptor that points to the parent process (and possibly child processes as well). Whether it is or isn't used as a key part of the structure is a design decision. One of the many things that come into play when deciding such a thing is for example what happens once the parent process exits - on UNIX the |
||||
|