Re: Differences between FreeBSD and Linux system call mechanism

H. Peter Anvin (hpa@transmeta.com)
3 Sep 1998 19:32:49 GMT


Followup to: <35EE64B7.9006093A@darmstadt.gmd.de>
By author: Joerg Pommnitz <pommnitz@darmstadt.gmd.de>
In newsgroup: linux.dev.kernel
>
> in freebsd-current Terry Lambert wrote:
>
> > Linux uses a call-gate based kernel entry, which is TSS based, and
> > therefore takes more CPU cycles on a contect switch than strictly
> > required. The FreeBSD mechanism for kernel entry (and subsequet
> > context switch) is threfore more efficient than that used by Linux.
>
> I'm starting to wonder. Terry normally knows what he is talking about,
> but this posting seems to contain various mistakes:
>
> 1) Linux system calls are done using software interrupt 0x80 on ia32.
> Does this qualify as a "call-gate based kernel entry"?

It's an interrupt gate, not a call gate; the distinction is subtle.
Incidentally, *NEITHER* is "TSS based"; that would be a task gate.
Now, very recent Intel processors (Pentium II and newer) contain a new
SYSENTER instruction would would be a *lot* more efficient, but would
of course require wholesale libc changes.

> 2) I don't see the connection between kernel entry and TSS based task
> switch. Mingo already has patches that replace the current TSS method
> with software based context switchs.

Yes, task switches (NOT context switches) use the TSS. There are some
things that could make a non-TSS based system cheaper (mainly avoiding
to load all the segment registers) but the difference ain't that
great. Mingo's patches would eliminate the use of the hardware task
switch; the main reason isn't speed but the annoying 4000-process
limit that imposes, as well as better handling of the I/O bitmap.

> 3) I'm not sure about Terrys definition of "efficient", but if he means
> required CPU cycles I thought that there were not that many left in
> Linux that FreeBSD could be better. Has anybody hard numbers for both
> kernels?

No hard numbers, but Terry seems to be letting his advocacy get away
of the facts in this particular case, I'm sorry to say.

-hpa

-- 
    PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD  1E DF FE 69 EE 35 BD 74
    See http://www.zytor.com/~hpa/ for web page and full PGP public key
        I am Bahá'í -- ask me about it or see http://www.bahai.org/
   "To love another person is to see the face of God." -- Les Misérables

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html