Task State Segment: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
m →‎x86_64 Structure: Clarify meaning of PL (took me a while to figure this out)
Line 195:
 
==TSS in software multitasking==
For each CPU which executes processes possibly wanting to do system calls via interrupts, one TSS is required. The only interesting fields are SS0 and ESP0. Whenever a system call occurs, the CPU gets the SS0 and ESP0-value in its TSS and assigns the stack-pointer to it. So one or more kernel-stacks need to be set up for processes doing system calls. Be aware that a thread's/process' time-slice may end during a system call, passing control to another thread/process which may as well perform a system call, ending up in the same stack. Solutions are to create a private kernel-stack for each thread/process and re-assign esp0 at any task-switch or to disable scheduling during a system-call (see also [[Kernel Multitasking]]).
 
Setting up a TSS is straight-forward. An entry in the [[Global Descriptor Table]] is needed (see also the [[GDT_Tutorial#Flat_Setup|GDT Tutorial]]), specifying the TSS' address as "base", TSS' size as "limit", 0x89 (Present|Executable|Accessed) as "access byte" and 0x40 (Size-bit) as "flags".