Date: Wed, 13 Oct 1999 14:41:48 -0600 From: Wes Peters <wes@softweyr.com> To: Patrick Hartling <patrick@137.org> Cc: freebsd-realtime@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG Subject: Re: Comparing pthread_t's in user-level code Message-ID: <3804EE8C.413D3EF2@softweyr.com> References: <19991012203841.B82FE5D99@friley-161-13.res.iastate.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
Patrick Hartling wrote: > > I'm working on a project wherein we are putting pthread_t structures into > a thread manager (a C++ STL map), and we want to be able to maintain the > structures in an ordered fashion for performance reasons. To do this, we > need a way to compare the structures. pthread_equal(3) gets us an > equality comparison, but I cannot find anything for doing a less-than > comparison. On FreeBSD in particular, the pthread_t structure's contents > are not accessible to user-level code (as far as I can tell), so that is > providing some complication. pthread_set_name_np() looks very promising > since we could use strcmp(3) for doing less-than comparisons, but I cannot > find any facility for retrieving a thread's name once it is set. I've been > looking through header files, the libc_r source and the mailing list > archives but have come up empty thus far. Is there some method to get a > unique identifer for a pthread_t that can be used for comparison with other > pthread_t's, or do we have to stick with pthread_equal(3) alone? A pthread_t is a pointer to a struct pthread. If you don't need any specific ordering, you could simply sort on the pthread_t itself, treating it as an unsigned integer value. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-realtime" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3804EE8C.413D3EF2>