Hello,
I plan having thread support managed by the kernel. However, a small issue came to my mind.
Assume the kernel we are talking about isn't preemptible (cli while in kernel mode) and is always on uniprocessor. Assume too that we are using software task switching.
Each thread needs it's private stack, so that their executions don't conflict with each other, right? However, the TSS makes the processor always switch to the same stack when a software interrupt causes a switch to Ring 0.
Given that, what's the "usual" procedure to have the thread use it's own stack?
* The solution I plan to implement is, whenever a thread enters kernel somehow that it will for sure need to yield execution (ex. timer interrupt, or disk request), copy the "default" Ring 0 stack contents already created to the thread's private stack.
* Another solution I foresee would be patch the TSS every time one switches threads (and before going to user mode). However, this would require reloading the Task Register, afaik, which takes time.
Any other suggestion?
JJ
Thread-wise stack switch
Re: Thread-wise stack switch
"Patching" the TSS by fixing the stack pointer contained in the TSS does not require reloading the task register. That is the normal method.
Re: Thread-wise stack switch
Thanks.bewing wrote:"Patching" the TSS by fixing the stack pointer contained in the TSS does not require reloading the task register. That is the normal method.
JJ

