c - Why and in what sense is pthread_t an opaque type? -
posts here on suggest pthread_t
opaque type, not number, not thread index, shouldn't directly compare pthread_t's, etc. etc.
questions:
why? there intent support systems no numeric ids threads? when pthread_t implementation
typedef unsigned long int pthread_t;
?
how? there's comment before above line, it's actually
/* thread identifiers. structure of attribute type not exposed on purpose. */ typedef unsigned long int pthread_t;
in
pthreadtypes.h
mean? attribute type? isn't index global table of threads?
is there intent support systems no numeric ids threads?
there different types serve numeric thread identifier. example, on systems limited resources 8-bit thread identifier used instead of unsigned long
.
the structure of attribute type not exposed on purpose.
the comment not pthread_t
definition, pthread_attr_t
definition 1 line below:
typedef union { char __size[__sizeof_pthread_attr_t]; long int __align; } pthread_attr_t;
the comment states char __size[__sizeof_pthread_attr_t]
used in order hide content of actual struct
.
isn't [
pthread_t
] index global table of threads?
it not have be. fact actual type hidden allows implementer use type wishes, including pointer or struct
. using struct
lets implementer avoid using global table of threads in code of library (os keep such table, though).
Comments
Post a Comment