From owner-freebsd-hackers@freebsd.org Mon Apr 30 17:49:57 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89522FB1CBF for ; Mon, 30 Apr 2018 17:49:57 +0000 (UTC) (envelope-from jan@digitaldaemon.com) Received: from digitaldaemon.com (digitaldaemon.com [162.217.114.50]) by mx1.freebsd.org (Postfix) with SMTP id 3489D7BF22 for ; Mon, 30 Apr 2018 17:49:57 +0000 (UTC) (envelope-from jan@digitaldaemon.com) Received: (qmail 2411 invoked by uid 89); 30 Apr 2018 17:49:54 -0000 Received: from c-24-0-179-87.hsd1.nj.comcast.net (HELO iMac.local) (jan@digitaldaemon.com@24.0.179.87) by digitaldaemon.com with SMTP; 30 Apr 2018 17:49:54 -0000 Subject: Re: Getting pthread names To: Richard Yao Cc: =?UTF-8?Q?Manuel_St=c3=bchn?= , freebsd-hackers@freebsd.org References: <20180430111434.GA18085@freebsd-t450.fritz.box> <7d26b9d2-0f1e-2103-941a-c9c608b4e4fa@digitaldaemon.com> <64966B3E-41FE-44A5-A85D-A96EF89B22ED@gentoo.org> From: Jan Knepper Message-ID: Date: Mon, 30 Apr 2018 13:49:54 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <64966B3E-41FE-44A5-A85D-A96EF89B22ED@gentoo.org> Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2018 17:49:57 -0000 On 04/30/2018 10:53, Richard Yao wrote: > > > On Apr 30, 2018, at 10:24 AM, Jan Knepper > wrote: > >> I think the pthread_set_name_np(3) function is for debugging >> (reporting) purposes. > > It is. :-) >> >> The names show up when you use 'procstat', 'top', 'ps', etc. >> >> If you want to give a thread a name and use that name later in code >> why not keep that internally in you thread management structures/code >> and use that same name in the call to pthread_set_name_np? > > I cannot speak for him, but sometimes it is easier to just let the OS > do stuff for you. That being said, if that is what he wants, it would > be trivial to do using thread specific data: My experience as a software engineer is... If the OS or (standard) library can do something for you, let the OS or (standard) library do it. So, agreed. It is also 'trivial' to do when you have any form or thread management or any form of thread data. Indeed using a 'thread specific data' solution might be helpful. > >> >> On 04/30/2018 07:14, Manuel Stühn wrote: >>> Hi, >>> >>> for setting a name for pthreads i found pthread_set_name_np(3), but >>> for retrieving the name i found nothing. Is there any api like >>> pthread_getname_np for FreeBSD? Or is there another way to retrieve >>> the threads name within an application? >>> >>> _______________________________________________ >> ManiaC++ Jan Knepper