aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1997-12-30 20:11:01 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1997-12-30 20:11:01 +0000
commitcf26fc706f8a1b85325964e76717fa271e857514 (patch)
tree608a5400546b3d13c1e378ff6223b11c497a0c25 /sys/i386
parent05d83ad6a4084245afb5c0d490702727f11f5fe9 (diff)
downloadsrc-cf26fc706f8a1b85325964e76717fa271e857514.tar.gz
src-cf26fc706f8a1b85325964e76717fa271e857514.zip
Fix a race condition I introduced.
Reviewed by: bde (with only minor complaints :-)
Notes
Notes: svn path=/head/; revision=32126
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/microtime.s22
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/i386/i386/microtime.s b/sys/i386/i386/microtime.s
index df64698d327e..93b0f19c6cd3 100644
--- a/sys/i386/i386/microtime.s
+++ b/sys/i386/i386/microtime.s
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: Steve McCanne's microtime code
- * $Id: microtime.s,v 1.38 1997/12/28 13:36:05 phk Exp $
+ * $Id: microtime.s,v 1.39 1997/12/28 17:32:59 phk Exp $
*/
#include <machine/asmacros.h>
@@ -56,9 +56,22 @@ ENTRY(microtime)
subl _tsc_bias, %eax
mull _tsc_multiplier
movl %edx, %eax
+ addl _time+4, %eax /* usec += time.tv_sec */
+ movl _time, %edx /* sec = time.tv_sec */
popfl /* restore interrupt mask */
- jmp common_microtime
+ cmpl $1000000, %eax /* usec valid? */
+ jb 1f
+ subl $1000000, %eax /* adjust usec */
+ incl %edx /* bump sec */
+1:
+ movl 4(%esp), %ecx /* load timeval pointer arg */
+ movl %edx, (%ecx) /* tvp->tv_sec = sec */
+ movl %eax, 4(%ecx) /* tvp->tv_usec = usec */
+
+ ret
+
+ ALIGN_TEXT
i8254_microtime:
movb $TIMER_SEL0|TIMER_LATCH, %al /* prepare to latch */
@@ -210,13 +223,12 @@ overflow:
popl %edx
popl %eax
#endif /* USE_CLOCKLOCK */
- popfl /* restore interrupt mask */
-
-common_microtime:
addl _time+4, %eax /* usec += time.tv_sec */
movl _time, %edx /* sec = time.tv_sec */
+ popfl /* restore interrupt mask */
+
cmpl $1000000, %eax /* usec valid? */
jb 1f
subl $1000000, %eax /* adjust usec */