nanosleep on x64
high-resolution sleep
sys_nanosleep(struct __kernel_timespec *rqtp, struct __kernel_timespec *rmtp)
| number | 35 (0x23) |
|---|---|
| abi | common |
| entry point | sys_nanosleep |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | nanosleep(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 35, the syscall number |
rdi | struct __kernel_timespec *rqtp |
rsi | struct __kernel_timespec *rmtp |
rax | the return value |
Then run syscall to enter the kernel.
The syscall instruction clobbers rcx (the return address lands in rcx) and r11 (the flags land in r11).
Since Linux 5.14 the kernel reads the syscall number from eax and ignores the upper 32 bits of rax. Older kernels fail with ENOSYS when those bits are not zero, and mov eax, N clears them, so it works on both.
Same syscall on other architectures
- x86 162
- arm64 101
- arm 162
- riscv64 101
- ia32 162
- x32 1073741859
- loongarch64 101
- ppc64 162
- ppc 162
- s390x 162
- mips64 5034
- mipsn32 6034
- mipso32 4166
- alpha 340
- arc 101
- blackfin 162, removed in 4.17
- cris 162, removed in 4.17
- csky 101
- frv 162, removed in 4.17
- hexagon 101
- ia64 1168, removed in 6.7
- m32r 162, removed in 4.17
- m68k 162
- metag 101, removed in 4.17
- microblaze 162
- mn10300 162, removed in 4.17
- nds32 101, removed in 5.18
- nios2 101
- openrisc 101
- parisc 162
- score 101, removed in 4.17
- sh 162
- sparc 249
- sparc64 249
- tilegx 101, removed in 4.17
- tilepro 101, removed in 4.17
- xtensa 195
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/nanosleep