Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task Switching in 64bit

Tags:

x86-64

tss

In x86, you can use the TSS for task switching between running processes, however, it is recommended to use only one TSS (as you have to) and perform software task switching, especially if you want to port the kernel to other hardware which don't have TSS's.

In x86-64 (64 bit), there is no TSS (e.g. it doesn't do anything like in x86), so, how would someone go about doing task switching without it (since before, you would use at least one)?

like image 224
mmk Avatar asked Aug 19 '14 21:08

mmk


1 Answers

You would do it the same way you would do it on any other platform: you store the contents of the appropriate registers:

  • the stack pointer
  • the instruction pointer
  • whichever general-purpose registers are appropriate for the architecture
  • any other state you need to maintain (FPU/MMX/SSE registers, etc.)

for the task you're switching away from, and restore the same for the task you're switching to.

Often this is done by pushing all the state onto the stack you're switching from, and popping it off the stack you're switching to. This way, only the stack pointer needs to be passed around or managed by the kernel to track what's waiting in the background.

like image 111
Adam Maras Avatar answered Oct 20 '22 01:10

Adam Maras