Code: Select all
struct Thread
{
Thread *NextThreadInProcess;
Thread *GlobalTreeLeft;
Thread *GlobalTreeRight;
Process *Parent;
/* ... */
};Code: Select all
struct Thread
{
Thread *NextThreadInProcess;
Thread *GlobalTreeLeft;
Thread *GlobalTreeRight;
Process *Parent;
/* ... */
};
Code: Select all
o
o o o
o o o o o o o o o Neo wrote: I do know what binary trees are.
I just wanted to know if anyone had some other method of using binary trees for PID's when a parent has more than 2 directly realted children.
If not then I don't think we could use binary tree for a process hierarchy.
Corrections and Suggestions welcome.

From a practical point of view, I'd use a linked list. It's easy to implement, doesn't have a lot of overhead and there's no point trying to get more performance. You're mainly going to use it for killing child threads -> you'll always need all of them then.Neo wrote: Ok (got that cleared at last).
So do you use a splay tree for this or is that overkill.
From an even more practical point of view, first decide on how your OS will behave - specifically, what the relationship between processes, threads, etc will be.Candy wrote:From a practical point of view, I'd use a linked list. It's easy to implement, doesn't have a lot of overhead and there's no point trying to get more performance. You're mainly going to use it for killing child threads -> you'll always need all of them then.
I like this idea and have been planning to implement it as well. However, I was thinking to "re-parent" all graphical processes to the GUI/window manager process so that they will at least stay a part of the process tree and could all be killed by killing the GUI process. Not sure if that is where I'll end up going or not...Brendan wrote: For a command line environment where the CLI is unusable until you exit the text editor it makes more sense for the text editor to be a child process. For a GUI environment, it's better to be able to start 5 text editors and exit the CLI leaving the text editors running.
I'm using "connections to a user interface", where a single thread can have multiple connections to multiple user interfaces. When UI connections need to be broken by the UI (for e.g. if the user logs off), the UI sends a "disconnected" message to each of it's clients and ignores anything they send after that.HOS wrote:I like this idea and have been planning to implement it as well. However, I was thinking to "re-parent" all graphical processes to the GUI/window manager process so that they will at least stay a part of the process tree and could all be killed by killing the GUI process. Not sure if that is where I'll end up going or not...Brendan wrote: For a command line environment where the CLI is unusable until you exit the text editor it makes more sense for the text editor to be a child process. For a GUI environment, it's better to be able to start 5 text editors and exit the CLI leaving the text editors running.