Date: Fri, 11 Jul 2003 02:34:14 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: deischen@freebsd.org Cc: freebsd-threads@freebsd.org Subject: Re: null pthread_t Message-ID: <3F0E8496.CBDCC23B@mindspring.com> References: <Pine.GSO.4.10.10307100852420.2454-100000@pcnet5.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F0E8496.CBDCC23B>