The
process id directories in /proc provide a fair bit of information.
First call
getpid, then you can search through the process directories to find those threads that are related to the same process.
The command
pstree will give you something of a feel for how thread and process ids work, before you write your own implementation.