From 665b9b3476ad0a6dc4e578e42e6c63012e23aaa0 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 20 Apr 2018 15:30:52 -0700 Subject: runtime: change GNU/Linux usleep to use nanosleep Ever since we added sleep to the runtime back in 2008, we've implemented it on GNU/Linux with the select (or pselect or pselect6) system call. But the Linux kernel has a nanosleep system call, which should be a tiny bit more efficient since it doesn't have to check to see whether there are any file descriptors. So use it. Change-Id: Icc3430baca46b082a4d33f97c6c47e25fa91cb9a Reviewed-on: https://go-review.googlesource.com/108538 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/runtime/sys_linux_mipsx.s | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/runtime/sys_linux_mipsx.s') diff --git a/src/runtime/sys_linux_mipsx.s b/src/runtime/sys_linux_mipsx.s index fb6130ac3a..52eccca093 100644 --- a/src/runtime/sys_linux_mipsx.s +++ b/src/runtime/sys_linux_mipsx.s @@ -26,8 +26,8 @@ #define SYS_munmap 4091 #define SYS_setitimer 4104 #define SYS_clone 4120 -#define SYS_newselect 4142 #define SYS_sched_yield 4162 +#define SYS_nanosleep 4166 #define SYS_rt_sigreturn 4193 #define SYS_rt_sigaction 4194 #define SYS_rt_sigprocmask 4195 @@ -115,19 +115,16 @@ TEXT runtimeĀ·usleep(SB),NOSPLIT,$28-4 DIVU R4, R3 MOVW LO, R3 MOVW R3, 24(R29) + MOVW $1000, R4 MULU R3, R4 MOVW LO, R4 SUBU R4, R5 MOVW R5, 28(R29) - // select(0, 0, 0, 0, &tv) - MOVW $0, R4 + // nanosleep(&ts, 0) + ADDU $24, R29, R4 MOVW $0, R5 - MOVW $0, R6 - MOVW $0, R7 - ADDU $24, R29, R8 - MOVW R8, 16(R29) - MOVW $SYS_newselect, R2 + MOVW $SYS_nanosleep, R2 SYSCALL RET -- cgit v1.3