chaos4ever / chaos

The chaos Operating System
https://chaos4ever.github.io/
16 stars 7 forks source link

Convert to not use hardware multitasking #91

Open perlun opened 7 years ago

perlun commented 7 years ago

This issue reminded me of a somewhat "odd" fact: in the storm kernel, we use the hardware multitasking capabilities of the x86 CPU. This is a bit uncommon; other systems like Linux and Windows 98 do not use this. Instead, they perform the handling of task state themselves.

This osdev page lists some of the reasons why hardware/TSS-based is a bad idea:

The TSS can be used for multitasking, though it is recommended to use software multitasking for these reasons:

  • Software task switching is faster(usually)
  • When you port your OS to a different CPU, it won't have the TSS, so you'll have to implement software task switching anyway
  • x86 64bit mode does not allow you to use the TSS for task switching.

Since we are indeed looking into porting this to RPi (with @johannesl), we will likely have to implement software-based task switching anyway, so if not earlier, we will have to deal with this by then.

Quoting from the issue mentioned at the top of this page:

This feature is hardware multitasking, see https://pdos.csail.mit.edu/6.828/2011/readings/i386/c07.htm

Any suggestions for how to refactor our code to not use system segment descriptors?

For starters, the steps described in https://pdos.csail.mit.edu/6.828/2011/readings/i386/s07_05.htm need to be executed manually and the call can be replaced with a normal far call (or iret). See also http://wiki.osdev.org/Getting_to_Ring_3#The_TSS and http://wiki.osdev.org/Context_Switching

This would be needed to get #80 sorted out, at least if we want to use the v86 approach.