Page 1 of 1

On threads and processes

Posted: Sat Feb 28, 2009 10:03 pm
by Steve the Pirate
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.

Re: On threads and processes

Posted: Sun Mar 01, 2009 6:15 am
by Steve the Pirate
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.