Alex Rivera | Logout

Why doesn't Linux use the hardware context switch via the TSS?

Asked 2010-04-26T03:46:33.180
45

I read the following statement:

The x86 architecture includes a specific segment type called the Task State Segment (TSS), to store hardware contexts. Although Linux doesn't use hardware context switches, it is nonetheless forced to set up a TSS for each distinct CPU in the system.

I am wondering:

  • Why doesn't Linux use the hardware support for context switch?
  • Isn't the hardware approach much faster than the software approach?
  • Is there any OS which does take advantage of the hardware context switch? Does windows use it?

At last and as always, thanks for your patience and reply.

-----------Added--------------

http://wiki.osdev.org/Context_Switching got some explanation.

People as confused as me could take a look at it. 8^)

Edit
Report

1 Answer

20

Linux used to use HW-based switching, in the pre-1.3 timeframe iirc. I believe sw-based context switching turned out to be faster, and it is more flexible.

Another reason may have been minimizing arch-specific code. The first port of Linux to a non-x86 architecture was Alpha. Alpha didn't have TSS, so more code could be shared if all archs used SW switching. (Just a guess.) Unfortunately the kernel changelogs for the 1.2-1.3 kernel period are not well-preserved, so I can't be more specific.

answered 2010-05-03T21:34:50.303

Your Answer