Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Nov 1999 18:57:28 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        David Greenman <dg@root.com>
Cc:        Julian Elischer <julian@whistle.com>, current@FreeBSD.ORG
Subject:   Re: Which is the truth? (sycalls and traps) 
Message-ID:  <199911280257.SAA40292@apollo.backplane.com>
References:   <199911252215.OAA14800@implode.root.com>

next in thread | previous in thread | raw e-mail | index | archive | help
:>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 
					<dillon@backplane.com>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911280257.SAA40292>