I consider myself quite a good C++ programmer, and I like to "follow the rules". But I can't solve this
design problem.
It's all about my scheduler. Basically I have a Process class which contains a List<Thread *> member with pointers to it's threads.
The Process class contains PID, process path, the address space (PML4) and something more, while each thread has it's own TID, cpu context and a few other variables, AND a pointer to the parent Process.
Code: Select all
class Process
{
...
List<Thread *> threads;
...
};
class Thread
{
...
Process *parentProcess;
...
}
Everywhere I read on the web, this is highly discouraged: "Two classes needing each other would better be a single class.", and things like that. However I really need the ParentProcess pointer to read the AddressSpace field which is global to each process and not thread-specific. Having a copy of AddressSpace in each thread would be rather redundant and error-prone.
Even though my code would just work like this, I would like to remove this ugly thing from my code base. Any suggestions?
Please, correct my English...
Motherboard: ASUS Rampage II Extreme
CPU: Core i7 950 @ 3.06 GHz OC at 3.6 GHz
RAM: 4 GB 1600 MHz DDR3
Video: nVidia GeForce 210 GTS... it sucks...