From owner-freebsd-current Sat Nov 27 18:57:35 1999 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 4F5A814CA5 for ; Sat, 27 Nov 1999 18:57:32 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id SAA40292; Sat, 27 Nov 1999 18:57:28 -0800 (PST) (envelope-from dillon) Date: Sat, 27 Nov 1999 18:57:28 -0800 (PST) From: Matthew Dillon Message-Id: <199911280257.SAA40292@apollo.backplane.com> To: David Greenman Cc: Julian Elischer , current@FreeBSD.ORG Subject: Re: Which is the truth? (sycalls and traps) References: <199911252215.OAA14800@implode.root.com> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :>Am I also right in assuming that all the registers that the user was :>running when they did the KERNCALL have been saved on the KERNEL stack by :>the time that the above routines are called? : : No, that's what the pushal (push all) does. : :-DG : :David Greenman pushing/popping integer registers doesn't really take a whole lot of time. The real overhead is with all the junk we have on entering and exiting from a kernel context from/to a user context. In fact, for kernel threads it's even easier: If you are calling the switch code synchronously then, of course, the scratch-on-call registers need not be saved or restored either. It's as simple as the code I've shown below, taken from one of my other projects: pushfl pushl %ebx pushl %ebp pushl %esi pushl %edi pushl $myresumefunction movl %esp,ta_Ctx+mc_SP(%ecx) Switch to new task: movl ta_Ctx+mc_SP(%ecx),%esp ret And the restore function: popl %edi popl %esi popl %ebp popl %ebx popfl ... Enhance as required (i.e. other registers need to be added if an interrupt, segment registers, and so forth. note: pushal/popal does not mess with the segment registers or the FP registers. It is not all-inclusive. Only the main registers are pushed/popped. -Matt Matthew Dillon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message