In microtime(), use pushfl/popfl to preserve the interrupt enable flag

instead of sti to it restore to its usual state.  pushfl/popfl is
actually faster in protected mode on Pentiums (4+3 cycles instead of 9),
and using sti made it extremely inconvenient to call microtime() from
fast interrupt handlers.  pushfl/popfl is a couple of cycles slower than
sti on 486's and a couple more cycles slower on 386's, but the relative
cost of using it is not large since microtime() has to use slow i/o
instructions on the old cpus.
This commit is contained in:
Bruce Evans 1996-06-17 12:43:04 +00:00
parent 1d2387de61
commit b7911dc3bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16427

View File

@ -32,7 +32,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: Steve McCanne's microtime code * from: Steve McCanne's microtime code
* $Id: microtime.s,v 1.12 1995/12/24 08:10:43 davidg Exp $ * $Id: microtime.s,v 1.13 1996/05/31 01:08:02 peter Exp $
*/ */
#include <machine/asmacros.h> #include <machine/asmacros.h>
@ -54,6 +54,7 @@ ENTRY(microtime)
movb $TIMER_SEL0|TIMER_LATCH, %al /* prepare to latch */ movb $TIMER_SEL0|TIMER_LATCH, %al /* prepare to latch */
pushfl
cli /* disable interrupts */ cli /* disable interrupts */
outb %al, $TIMER_MODE /* latch timer 0's counter */ outb %al, $TIMER_MODE /* latch timer 0's counter */
@ -168,7 +169,7 @@ common_microtime:
addl _time+4, %eax /* usec += time.tv_sec */ addl _time+4, %eax /* usec += time.tv_sec */
movl _time, %edx /* sec = time.tv_sec */ movl _time, %edx /* sec = time.tv_sec */
sti /* enable interrupts */ popfl /* restore interrupt mask */
cmpl $1000000, %eax /* usec valid? */ cmpl $1000000, %eax /* usec valid? */
jb 1f jb 1f
@ -184,6 +185,7 @@ common_microtime:
#if defined(I586_CPU) || defined(I686_CPU) #if defined(I586_CPU) || defined(I686_CPU)
ALIGN_TEXT ALIGN_TEXT
pentium_microtime: pentium_microtime:
pushfl
cli cli
.byte 0x0f, 0x31 /* RDTSC */ .byte 0x0f, 0x31 /* RDTSC */
subl _i586_ctr_bias, %eax subl _i586_ctr_bias, %eax