9.25 gettid

int gettid(void);

This syscall returns the current thread id. It never fails.