public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Use adaptive mutex with std::mutex
@ 2023-04-18 21:37 H.J. Lu
  2023-04-19 20:16 ` Noah Goldstein
  0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2023-04-18 21:37 UTC (permalink / raw)
  To: GNU C Library

Hi,

Adaptive mutex works much better than normal mutex on machines with many cores.
However PTHREAD_MUTEX_ADAPTIVE_NP is a GNU extension and not supported
by std::mutex.  Is there a way to use adaptive mutex with std::mutex?  Glibc has

#define PTHREAD_MUTEX_INITIALIZER \
 { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_TIMED_NP) } }
#ifdef __USE_GNU
# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
 { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } }
# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
 { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } }
# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
 { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } }
#endif

Can we add a macro to conditonally define PTHREAD_MUTEX_INITIALIZER with
PTHREAD_MUTEX_ADAPTIVE_NP?

-- 
H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-29 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 21:37 Use adaptive mutex with std::mutex H.J. Lu
2023-04-19 20:16 ` Noah Goldstein
2023-04-29 15:34   ` Cristian Rodríguez

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).