Hi,
I have been starting to implement multitasking stuff in my kernel (written in C++) recently, and am thinking of doing an implementation similar to the Pedigree kernel, where I have a process class and a thread class. The scheduler would then have a vector of threads that it would schedule from. Now, as each process needs its own virtual address space, I am going to put that in its own class, which keeps track of the page directory, and wraps around the paging functions. Originally, I was planning on this keeping track also of the process' stack pointer, and base pointer, but now I've read that each thread has its own stack. So should I make a stack class to do this? How about the thread's instruction pointer - should I just store that as a member of the thread class, or keep that in the stack class?
Thanks.
On threads and processes
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
- Steve the Pirate
- Member
- Posts: 152
- Joined: Fri Dec 15, 2006 7:01 am
- Location: Brisbane, Australia
- Contact:
Re: On threads and processes
OK, so I'll put them in the thread class. I do think that I'll make a 'stack' class to abstract things like moving a thread's stack etc.
Just another thing, when you set up the scheduler, would you want to make a kernel process with one thread that finishes initialising the kernel, spawns the init process, and then returns, or would you disable interrupts, finish initialising, set up the init process, and then start interrupts again? I guess the former sounds like a better solution.
Just another thing, when you set up the scheduler, would you want to make a kernel process with one thread that finishes initialising the kernel, spawns the init process, and then returns, or would you disable interrupts, finish initialising, set up the init process, and then start interrupts again? I guess the former sounds like a better solution.