null pthread_t
Terry Lambert
tlambert2 at mindspring.com
Fri Jul 11 02:37:56 PDT 2003
Daniel Eischen wrote:
> This doesn't work where pthread_t's are integer id's (perhaps
> used as indices into a lookup table to find the real pointer).
> An index of 0 may be a valid thread id (which is why I assume
> it was set to -1 in Linux).
>
> Unless you are advocating defining PTHREAD_NULL differently
> depending on the threads implementation... But the code
> should be rewritten to use a different method of validating
> the thread (use a flag, or encapsulate it in an application
> defined type along with a flag).
I forgot to add the cast-value.
And, no... it's definitely the wrong way to do things; if you
need something like this,it's *much* better to use a covariable
that's type invariant, e.g. "int started_thread_flag = 0;".
And even -1 isn't safe; it might be a valid negative index. 8-).
-- Terry
More information about the freebsd-threads
mailing list