Should I use hardware multitasking via the TSS, or software multitasking with minimal TSS?
Which option is faster? Which is easier to program? I already know that hardware multitasking is not portable.
Hardware or software multitasking?
-
- Member
- Posts: 799
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Hardware or software multitasking?
Software. It is faster. x86-64 long mode dropped support for it as well.
Re: Hardware or software multitasking?
Software is probably going to be a better choice.
I'd say they're both pretty much as easy, so no significant difference there.
Portability is also a non-issue, non of the hardware related stuff is portable anyway.
As for speed, I'm not sure. The general opinion is that software is faster, and it probably is for many kernel designs. For instance many syscalls don't actually switch processes and don't necessarily need to save much of the context. Assuming you do all the things that a hardware task switch does, then I doubt doing it manually in software is going to be faster. But if you don't do all the things then software can be faster.
And finally, as already mentioned, long mode doesn't support it. So if you want to do long mode there's no option.
Personally I wouldn't bother with hardware tasks witching mainly due to long mode support missing and prot mode is pretty much obsolete.
I'd say they're both pretty much as easy, so no significant difference there.
Portability is also a non-issue, non of the hardware related stuff is portable anyway.
As for speed, I'm not sure. The general opinion is that software is faster, and it probably is for many kernel designs. For instance many syscalls don't actually switch processes and don't necessarily need to save much of the context. Assuming you do all the things that a hardware task switch does, then I doubt doing it manually in software is going to be faster. But if you don't do all the things then software can be faster.
And finally, as already mentioned, long mode doesn't support it. So if you want to do long mode there's no option.
Personally I wouldn't bother with hardware tasks witching mainly due to long mode support missing and prot mode is pretty much obsolete.
Re: Hardware or software multitasking?
It should also be noted that hardware task switching cannot be used to change MSRs or segment bases. It also does not support (actually not so) newer CPU features like the FPU/SSE state. So the question is not hardware vs. software switching but software vs. hybrid switching and software wins by a large margin in this comparison (for reasons that have already been stated).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].