What are bsdthread_register, ulock_wake and other system calls reported by dtruss?

330 Views Asked by At

Here is an example interaction with dtruss on my macOS machine.

$ cat main.c
int main() {
  return 0;
}
$ clang main.c
$ sudo dtruss ./a.out
dtrace: system integrity protection is on, some features will not be available

SYSCALL(args)        = return
open("/dev/dtracehelper\0", 0x2, 0x7FFF5AF83930)         = 3 0
ioctl(0x3, 0x80086804, 0x7FFF5AF838B8)       = 0 0
close(0x3)       = 0 0
thread_selfid(0x3, 0x80086804, 0x7FFF5AF838B8)       = 5434813 0
bsdthread_register(0x7FFFAF245080, 0x7FFFAF245070, 0x2000)       = 1073741919 0
ulock_wake(0x1, 0x7FFF5AF830EC, 0x0)         = -1 Err#2
issetugid(0x1, 0x7FFF5AF830EC, 0x0)      = 0 0
mprotect(0x104C7F000, 0x88, 0x1)         = 0 0
mprotect(0x104C81000, 0x1000, 0x0)       = 0 0
mprotect(0x104C97000, 0x1000, 0x0)       = 0 0
mprotect(0x104C98000, 0x1000, 0x0)       = 0 0
mprotect(0x104CAE000, 0x1000, 0x0)       = 0 0
mprotect(0x104CAF000, 0x1000, 0x1)       = 0 0
mprotect(0x104C7F000, 0x88, 0x3)         = 0 0
mprotect(0x104C7F000, 0x88, 0x1)         = 0 0
getpid(0x104C7F000, 0x88, 0x1)       = 34522 0
stat64("/AppleInternal/XBS/.isChrooted\0", 0x7FFF5AF82FA8, 0x1)      = -1 Err#2
stat64("/AppleInternal\0", 0x7FFF5AF83040, 0x1)      = -1 Err#2
csops(0x86DA, 0x7, 0x7FFF5AF82AD0)       = -1 Err#22
dtrace: error on enabled probe ID 2158 (ID 552: syscall::sysctl:return): invalid kernel access in action #10 at DIF offset 40
ulock_wake(0x1, 0x7FFF5AF83050, 0x0)         = -1 Err#2
csops(0x86DA, 0x7, 0x7FFF5AF823B0)       = -1 Err#22

Many of these system calls look familiar, but others don't. Specifically, what are thread_selfid, bsdthread_register, ulock_wake, csops, and dtrace? If these are system calls, they don't have man pages documenting them. Are they private system calls, or something else? Where does dtruss get their names from?

1

There are 1 best solutions below

0
On

Yes, ULOCK_wake is part of a private systemcall for threads afaik. You can see it in the xnu sourcecode as being systemcall number 516.