From owner-freebsd-realtime Tue Oct 12 13:38:46 1999 Delivered-To: freebsd-realtime@freebsd.org Received: from friley-160-236.res.iastate.edu (friley-160-236.res.iastate.edu [129.186.160.236]) by hub.freebsd.org (Postfix) with ESMTP id EDB0E14C0A; Tue, 12 Oct 1999 13:38:43 -0700 (PDT) (envelope-from patrick@137.org) Received: from friley-161-13.res.iastate.edu (friley-161-13.res.iastate.edu [129.186.161.13]) by friley-160-236.res.iastate.edu (Postfix) with ESMTP id B93DC104; Tue, 12 Oct 1999 15:38:42 -0500 (CDT) Received: from friley-161-13.res.iastate.edu (localhost [127.0.0.1]) by friley-161-13.res.iastate.edu (Postfix) with ESMTP id B82FE5D99; Tue, 12 Oct 1999 15:38:41 -0500 (CDT) To: freebsd-realtime@freebsd.org, freebsd-questions@freebsd.org Subject: Comparing pthread_t's in user-level code Date: Tue, 12 Oct 1999 15:38:41 -0500 From: Patrick Hartling Message-Id: <19991012203841.B82FE5D99@friley-161-13.res.iastate.edu> Sender: owner-freebsd-realtime@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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? -Patrick Patrick L. Hartling | Research Assistant, VRAC patrick@137.org | Carver Lab - 0095E Black Engineering http://www.137.org/patrick/ | http://www.vrac.iastate.edu/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-realtime" in the body of the message From owner-freebsd-realtime Wed Oct 13 13:42:12 1999 Delivered-To: freebsd-realtime@freebsd.org Received: from xylan.com (postal.xylan.com [208.8.0.248]) by hub.freebsd.org (Postfix) with ESMTP id 76AB014CB7; Wed, 13 Oct 1999 13:41:59 -0700 (PDT) (envelope-from wes@softweyr.com) Received: from mailhub.xylan.com by xylan.com (8.8.7/SMI-SVR4 (ind.alcatel.com 2.3 [OUT])) id NAA00555; Wed, 13 Oct 1999 13:41:51 -0700 (PDT) Received: from omni.xylan.com by mailhub.xylan.com (SMI-8.6/SMI-SVR4 (mailhub 2.1 [HUB])) id NAA05019; Wed, 13 Oct 1999 13:41:51 -0700 Received: from softweyr.com (dyn0.utah.xylan.com) by omni.xylan.com (4.1/SMI-4.1 (xylan engr [SPOOL])) id AA08143; Wed, 13 Oct 99 13:41:29 PDT Message-Id: <3804EE8C.413D3EF2@softweyr.com> Date: Wed, 13 Oct 1999 14:41:48 -0600 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.5 [en] (X11; U; FreeBSD 3.1-RELEASE i386) X-Accept-Language: en Mime-Version: 1.0 To: Patrick Hartling Cc: freebsd-realtime@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG Subject: Re: Comparing pthread_t's in user-level code References: <19991012203841.B82FE5D99@friley-161-13.res.iastate.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-realtime@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 From owner-freebsd-realtime Wed Oct 13 15:24:10 1999 Delivered-To: freebsd-realtime@freebsd.org Received: from friley-160-236.res.iastate.edu (friley-160-236.res.iastate.edu [129.186.160.236]) by hub.freebsd.org (Postfix) with ESMTP id 6BF791536B; Wed, 13 Oct 1999 15:23:57 -0700 (PDT) (envelope-from patrick@137.org) Received: from friley-161-13.res.iastate.edu (friley-161-13.res.iastate.edu [129.186.161.13]) by friley-160-236.res.iastate.edu (Postfix) with ESMTP id D403A104; Wed, 13 Oct 1999 16:32:07 -0500 (CDT) Received: from friley-161-13.res.iastate.edu (localhost [127.0.0.1]) by friley-161-13.res.iastate.edu (Postfix) with ESMTP id 351A85D71; Wed, 13 Oct 1999 16:32:07 -0500 (CDT) To: Wes Peters Cc: freebsd-realtime@FreeBSD.ORG, freebsd-questions@FreeBSD.ORG Subject: Re: Comparing pthread_t's in user-level code In-reply-to: Message from Wes Peters of "Wed, 13 Oct 1999 14:41:48 MDT." <3804EE8C.413D3EF2@softweyr.com> Date: Wed, 13 Oct 1999 16:32:07 -0500 From: Patrick Hartling Message-Id: <19991013213207.351A85D71@friley-161-13.res.iastate.edu> Sender: owner-freebsd-realtime@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Wes Peters wrote: } 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. Thanks, I hadn't been able to find the typdef for pthread_t in -current, but it was pointed out to me in -stable (I'm running both but developing primarily in -current). I've tried this, and it is working, so I'm quite happy. Now I have to deal with all the other aspects of the project that aren't porting easily from IRIX. :\ -Patrick Patrick L. Hartling | Research Assistant, VRAC patrick@137.org | Carver Lab - 0095E Black Engineering http://www.137.org/patrick/ | http://www.vrac.iastate.edu/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-realtime" in the body of the message