From owner-freebsd-arch Thu Dec 9 12:12:48 1999 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id F389515703 for ; Thu, 9 Dec 1999 12:12:39 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id VAA07115 for ; Thu, 9 Dec 1999 21:12:38 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id VAA31112 for freebsd-arch@freebsd.org; Thu, 9 Dec 1999 21:12:37 +0100 (MET) Received: from mail.tvol.com (mail.wgate.com [38.219.83.4]) by hub.freebsd.org (Postfix) with ESMTP id 89DDD156F6 for ; Thu, 9 Dec 1999 12:07:48 -0800 (PST) (envelope-from rjesup@wgate.com) Received: from jesup.eng.tvol.net (jesup.eng.tvol.net [10.32.2.26]) by mail.tvol.com (8.8.8/8.8.3) with ESMTP id OAA21413; Thu, 9 Dec 1999 14:51:27 -0500 (EST) Reply-To: Randell Jesup To: Julian Elischer Cc: arch@freebsd.org Subject: Re: kernel entry costs. References: From: Randell Jesup Date: 09 Dec 1999 14:51:56 -0500 In-Reply-To: Julian Elischer's message of "Sun, 28 Nov 1999 14:11:13 -0800 (PST)" Message-ID: X-Mailer: Gnus v5.6.43/Emacs 20.4 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Julian Elischer writes: >> > Julian, you shouldn't worry about userland<->kernel context switchso much. >> > The overhead for going into the kernel and coming out again, if all the >> > cruft is removed, is *very* tiny -- it's almost like a subroutine call. >> >> I was rather suprised when I found out just how expensive kernel entry was >> some time ago.. What I was doing was a reentrant syscall that aquired no >> locks and ran about 5 instructions in kernel context.. Anyway, it took >> something like 300 times longer to do that (called via int $0x81) than to >> do a 'call' to equivalent code in userland. Anyway, with overheads on that >> scale, whether we push 5 or 8 or whatever registers in the handler is >> almost lost in the noise. > >the IDT vercor is read >leading to the Interrupt gate that must be read, [ lots of stuff snipped ] >the new segment registers are then loaded. The generic syscall code is >called, and the appropriate function is selected and called. > >on return, the return values are saved into the registers in a >towers of hanoi simulation as the registers are reloaded and the >segment registers are reloaded. Then the flags , SP and IP are reloaded. > >this is not an insignificant amount of work! Don't forget that even though it's 'invisible', there may be extra overhead involved in the page table changes and TLB reloads occuring, cache misses, etc. -- Randell Jesup, Worldgate Communications, ex-Scala, ex-Amiga OS team ('88-94) rjesup@wgate.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message