【发布时间】:2010-10-23 13:21:56
【问题描述】:
有人知道在 BSD 上将当前线程 ID 作为整数获取吗?
我找到了这个
#ifdef RTHREADS
299 STD { pid_t sys_getthrid(void); }
300 STD { int sys_thrsleep(void *ident, int timeout, void *lock); }
301 STD { int sys_thrwakeup(void *ident, int n); }
302 STD { int sys_threxit(int rval); }
303 STD { int sys_thrsigdivert(sigset_t sigmask); }
#else
299 UNIMPL
300 UNIMPL
301 UNIMPL
302 UNIMPL
303 UNIMPL
#endif
并尝试了 (long)syscall(229) 但不起作用(它崩溃了)。在 Linux 上,我可以通过系统调用 (long) syscall(224) 获取线程 ID,它给了我一个整数(通常是 4 位数字)。有人可以帮忙吗?!谢谢。
【问题讨论】:
标签: c multithreading bsd