3 ms·
There's some out there, but not much. I haven't been able to find any for things like bsdthread_create, other than reading the open source code that Apple put o
by ori_b 11y ago
There's some out there, but not much. I haven't been able to find any for things like bsdthread_create, other than reading the open source code that Apple put out for libpthread.
Thankfully, that code was available -- without it, I would have had no idea that the 'stack' parameter for bsdthread_create would act as the stack size, instead of as the a pointer to the top (or bottom) of the stack.
Although, that being said, I'm currently still stuck on getting it working. The test for spawning threads is fine when I run it under 'sudo dtruss test/spawn', but as soon as it's not under dtruss, it fails to spawn the thread.
EDIT: when I say "some", I should probably post a link.
http://dyjakan.sigsegv.pl/ http://dyjakan.sigsegv.pl/ is the most comprehensive documentation that I've been able to find.
There's also syscalls.master in the xnu source: http://www.opensource.apple.com/source/xnu/xnu-1504.3.12/bsd/kern/syscalls.master http://www.opensource.apple.com/source/xnu/xnu-1504.3.12/bsd...
- ndesaulniers 11y ago> The test for spawning threads is fine when I run it under 'sudo dtruss test/spawn', but as soon as it's not under dtruss, it fails to spawn the thread. Ah, the fated Heisenbug. I skipped over all of the calls in my dtruss example in this post, but I recall dtruss listing itself making a few syscalls. I wonder if a missing signal handler is to blame? Also, thanks for pointing out Apple's pthread implementation! Great idea!
- ori_b 11y agoYes, I've also seen those issues with dtruss -- it seems to work better when you run it separately in another terminal: sudo dtruss -n myprocname It doesn't seem to trace itself, and now your program can run as a regular user. And in my case, it even catches the failure for bsdthread_create, although it drops some of the arguments, and the ones it does show seem identical enough. (And no, it's not the sudo that's making it work.)
- ndesaulniers 11y agoI'm reading through https://opensource.apple.com/source/libpthread/libpthread-138.10.4/src/pthread.c https://opensource.apple.com/source/libpthread/libpthread-13... and https://opensource.apple.com/source/Libc/Libc-1082.20.4/gen/nanosleep.c https://opensource.apple.com/source/Libc/Libc-1082.20.4/gen/... now!