gettid on x64
get thread identification
sys_gettid(void)
| number | 186 (0xba) |
|---|---|
| abi | common |
| entry point | sys_gettid |
| since | Linux 3.3 or earlier (3.3 is the first release scanned for x64) |
| man page | gettid(2) |
| source | elixir.bootlin.com |
Registers
| register | value |
|---|---|
rax | 186, the syscall number |
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 224
- arm64 178
- arm 224
- riscv64 178
- ia32 224
- x32 1073742010
- loongarch64 178
- ppc64 207
- ppc 207
- s390x 236
- mips64 5178
- mipsn32 6178
- mipso32 4222
- alpha 378
- arc 178
- blackfin 224, removed in 4.17
- cris 224, removed in 4.17
- csky 178
- frv 224, removed in 4.17
- hexagon 178
- ia64 1105, removed in 6.7
- m32r 224, removed in 4.17
- m68k 221
- metag 178, removed in 4.17
- microblaze 224
- mn10300 224, removed in 4.17
- nds32 178, removed in 5.18
- nios2 178
- openrisc 178
- parisc 206
- score 178, removed in 4.17
- sh 224
- sparc 143
- sparc64 143
- tilegx 178, removed in 4.17
- tilepro 178, removed in 4.17
- xtensa 127
Get this as JSON: https://api.syscall.sh/v2/syscalls/x64/gettid