Switching tasks to 64-bit

In x86, you can use TSS to switch tasks between running processes, however, it is recommended to use only one TSS (as you need) and switch software tasks, especially if you want to port the kernel to another that do not have TSS.

In x86-64 (64 bit) there is no TSS (for example, it does nothing of the kind in x86), so how would someone go about switching tasks without it (since earlier you would use at least one)?

+8
x86-64 tss
source share
2 answers

You would do it the same way as on any other platform: you save the contents of the corresponding registers:

  • stack pointer
  • instruction pointer
  • depending on which general purpose registers are suitable for the architecture
  • any other state that needs to be maintained (FPU / MMX / SSE registers, etc.).

for the task you are switching from and restore it for the task you are switching to.

Often this is done by pushing the entire state onto the stack from which you are switching, and pushing it from the stack to which you are switching. Thus, only the stack pointer should be passed on or managed by the kernel to track pending in the background.

+7
source share

Actually, it seems that TSS exists in 64-bit mode , it is simply not used to switch the hardware context; instead, it is simply used to indicate the kernel stack if and when a transition to a higher privilege level occurs.

You still have to use software context switching to change control between different tasks.

+5
source share

All Articles