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_386.s | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/runtime/sys_linux_386.s') diff --git a/src/runtime/sys_linux_386.s b/src/runtime/sys_linux_386.s index 721551faec..8d5a4ff977 100644 --- a/src/runtime/sys_linux_386.s +++ b/src/runtime/sys_linux_386.s @@ -39,6 +39,7 @@ #define SYS_setittimer 104 #define SYS_clone 120 #define SYS_sched_yield 158 +#define SYS_nanosleep 162 #define SYS_rt_sigreturn 173 #define SYS_rt_sigaction 174 #define SYS_rt_sigprocmask 175 @@ -56,7 +57,6 @@ #define SYS_epoll_ctl 255 #define SYS_epoll_wait 256 #define SYS_clock_gettime 265 -#define SYS_pselect6 308 #define SYS_epoll_create1 329 TEXT runtime·exit(SB),NOSPLIT,$0 @@ -141,14 +141,10 @@ TEXT runtime·usleep(SB),NOSPLIT,$8 MULL DX MOVL AX, 4(SP) - // pselect6(0, 0, 0, 0, &ts, 0) - MOVL $SYS_pselect6, AX - MOVL $0, BX + // nanosleep(&ts, 0) + MOVL $SYS_nanosleep, AX + LEAL 0(SP), BX MOVL $0, CX - MOVL $0, DX - MOVL $0, SI - LEAL 0(SP), DI - MOVL $0, BP INVOKE_SYSCALL RET -- cgit v1.3