From: "Pedro Alves (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Tom Tromey <tromey@sourceware.org>, gdb-patches@sourceware.org
Subject: [review v4] Set names of worker threads
Date: Tue, 26 Nov 2019 19:38:00 -0000 [thread overview]
Message-ID: <20191126193807.3741E20AF6@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1571543710000.I60473d65ae9ae14d8c56ddde39684240c16aaf35@gnutoolchain-gerrit.osci.io>
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176
......................................................................
Patch Set 4:
(3 comments)
Some comments below. Nothing major.
| --- gdb/gdbsupport/thread-pool.c
| +++ gdb/gdbsupport/thread-pool.c
| @@ -22,15 +22,24 @@ #include "common-defs.h"
| #if CXX_STD_THREAD
|
| #include "gdbsupport/thread-pool.h"
| #include "gdbsupport/alt-stack.h"
| #include "gdbsupport/block-signals.h"
| #include <algorithm>
|
| +/* On the off chance that we have the pthread library on a Windows
| + host, but std::thread is not using it, avoid calling
| + pthread_setname_np on Windows. */
PS4, Line 31:
Meh. Judging from
<https://stackoverflow.com/questions/19250008/mingw-stdthread-with-
windows-api>, I think this could be solved. But yeah, we really don't
have to bend backwards in this initial patch.
| +#ifndef _WIN32
| +#ifdef HAVE_PTHREAD_SETNAME_NP
| +#include <pthread.h>
| +#endif
| +#endif
PS4, Line 36:
I'd rather this was:
#ifndef _WIN32
# ifdef HAVE_PTHREAD_SETNAME_NP
# define USE_PTHREAD_SETNAME_NP
# endif
#endif
#ifdef USE_PTHREAD_SETNAME_NP
# include <pthread.h>
#endif
so that below we don't duplicate the checks, and we'd have a single
place to edit in the future if the checks evolve. See below...
| +
| namespace gdb
| {
|
| /* The thread pool detach()s its threads, so that the threads will not
| prevent the process from exiting. However, it was discovered that
| if any detached threads were still waiting on a condition variable,
| then the condition variable's destructor would wait for the threads
| to exit -- defeating the purpose.
...
| @@ -57,14 +66,19 @@ thread_pool::set_thread_count (size_t num_threads)
| if (m_thread_count < num_threads)
| {
| /* Ensure that signals used by gdb are blocked in the new
| threads. */
| block_signals blocker;
| for (size_t i = m_thread_count; i < num_threads; ++i)
| {
| std::thread thread (&thread_pool::thread_function, this);
| +#ifndef _WIN32 /* See the comment at the top of the file. */
| +#ifdef HAVE_PTHREAD_SETNAME_NP
PS4, Line 75:
... here, we'd do:
#ifdef USE_PTHREAD_SETNAME_NP
| + pthread_setname_np (thread.native_handle (), "gdb worker");
| +#endif
| +#endif
| thread.detach ();
| }
| }
| /* If the new size is smaller, terminate some existing threads. */
| if (num_threads < m_thread_count)
| {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35
Gerrit-Change-Number: 176
Gerrit-PatchSet: 4
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-CC: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Tue, 26 Nov 2019 19:38:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
next prev parent reply other threads:[~2019-11-26 19:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-20 3:55 [review] " Tom Tromey (Code Review)
2019-10-20 21:02 ` [review v2] " Tom Tromey (Code Review)
2019-11-06 0:50 ` [review v3] " Pedro Alves (Code Review)
2019-11-26 19:38 ` Pedro Alves (Code Review) [this message]
2019-11-26 19:54 ` [review v4] " Tom Tromey (Code Review)
2019-11-26 21:14 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-11-26 21:21 ` Sourceware to Gerrit sync (Code Review)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191126193807.3741E20AF6@gnutoolchain-gerrit.osci.io \
--to=gerrit@gnutoolchain-gerrit.osci.io \
--cc=gdb-patches@sourceware.org \
--cc=gnutoolchain-gerrit@osci.io \
--cc=tromey@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).