Commit 37346638 authored by Joel Sing's avatar Joel Sing

runtime: use monotonic clock for openbsd/386 and openbsd/amd64 timers

Switch nanotime to a monotonic clock on openbsd/386 and openbsd/amd64.
Also use a monotonic clock when for thrsleep, since the sleep duration
is based on the value returned from nanotime.

Update #6007

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68460044
parent 66562b96
......@@ -82,7 +82,7 @@ runtime·semasleep(int64 ns)
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
ts.tv_nsec = 0;
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
runtime·thrsleep(&m->waitsemacount, CLOCK_REALTIME, &ts, &m->waitsemalock, nil);
runtime·thrsleep(&m->waitsemacount, CLOCK_MONOTONIC, &ts, &m->waitsemalock, nil);
}
// reacquire lock
while(runtime·xchg(&m->waitsemalock, 1))
......
......@@ -9,6 +9,8 @@
#include "zasm_GOOS_GOARCH.h"
#include "../../cmd/ld/textflag.h"
#define CLOCK_MONOTONIC $3
// Exit the entire program (like C exit)
TEXT runtime·exit(SB),NOSPLIT,$-4
MOVL $1, AX
......@@ -133,7 +135,7 @@ TEXT time·now(SB), NOSPLIT, $32
// void nanotime(int64 *nsec)
TEXT runtime·nanotime(SB),NOSPLIT,$32
LEAL 12(SP), BX
MOVL $0, 4(SP) // arg 1 - clock_id
MOVL CLOCK_MONOTONIC, 4(SP) // arg 1 - clock_id
MOVL BX, 8(SP) // arg 2 - tp
MOVL $87, AX // sys_clock_gettime
INT $0x80
......
......@@ -9,6 +9,8 @@
#include "zasm_GOOS_GOARCH.h"
#include "../../cmd/ld/textflag.h"
#define CLOCK_MONOTONIC $3
// int64 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
TEXT runtime·tfork(SB),NOSPLIT,$32
......@@ -166,7 +168,7 @@ TEXT time·now(SB), NOSPLIT, $32
RET
TEXT runtime·nanotime(SB),NOSPLIT,$24
MOVQ $0, DI // arg 1 - clock_id
MOVQ CLOCK_MONOTONIC, DI // arg 1 - clock_id
LEAQ 8(SP), SI // arg 2 - tp
MOVL $87, AX // sys_clock_gettime
SYSCALL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment