有誰知道在BSD上獲取當前線程ID爲整數?如何在C/C++的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
,並試圖(長)系統調用(229),但不工作(崩潰)。在Linux上,我可以通過系統調用(long)syscall(224)得到線程ID,它給了我一個整數(通常是4位數)。任何人都可以幫忙?謝謝。
對我而言是新的。很好的信息!非常感謝,歡呼! – Lini 2010-11-05 22:34:34
在FreeBSD上也有pthread_getthreadid_np()函數:https://www.freebsd.org/cgi/man.cgi?pthread_getthreadid_np – 2018-02-20 17:46:56