I have a thread
datatype in the interpreter implementation for a programming language I am working on. For various reasons, it’s a fairly common operation, to need to get the current thread
(which is, itself, a pointer: a struct thread*
).
However, pthread_self(3)
hands me a pthread_t
, which is an opaque type; on some systems, it seems to be an unsigned long
, but I hear I can’t depend on that being the case. I suspect a hash table is the proper implementation of this unique mapping (pthread_t
ID to struct thread
pointer); however, I have no idea how to hash the pthread_t
reliably.
I would appreciate advice from anybody with more experience with pthread(3)
or, really, any situation wherein you have to “hash” an opaque datatype.