Page 1 of 1

Switching out TSS

Posted: Sun May 17, 2009 7:29 am
by NickJohnson
In the current design of my OS, processes (or the kernel) are able to send "signals" to other processes - simple, synchronous, one way messages that preempt the receiver's current state. It is possible to have a signal preempt another signal's currently running signal handler.

The issue is that I can't get stuff to preempt, because the TSS's esp0 value is static, and the same, for all processes. The address of the TSS's esp0 points to a small stack used to save the process image, which I need to act as a stack of process images.

Regardless of if you understand what is happening, the point is that I want to be able to change the TSS's esp0 value on a process-by-process basis. This involves setting the TSS entry in the GDT to some area of memory that is switched out with each process. However, I do not and do not want to use the x86's hardware task switching. Is this possible, or do I have to come up with some other method?

Re: Switching out TSS

Posted: Sun May 17, 2009 10:31 am
by frank
My interrupt routine just patches the esp0 in the TSS for each task switch. That way there is always a valid esp0 in the TSS when a user thread is running.

Re: Switching out TSS

Posted: Sun May 17, 2009 10:48 am
by xenos
My (software based) task switcher does the same stuff that frank's task switcher does. The esp0 value is stored in the process structure and entered into the TSS on every task switch.