mirror of
https://github.com/python/cpython.git
synced 2025-08-28 12:45:07 +00:00
Improve threading on Solaris, according to SF patch #460269, submitted
by bbrox@bbrox.org / lionel.ulmer@free.fr. This adds a configure check and if all goes well turns on the PTHREAD_SCOPE_SYSTEM thread attribute for new threads. This should remove the need to add tiny sleeps at the start of threads to allow other threads to be scheduled.
This commit is contained in:
parent
47f40343b3
commit
d0b69eceb4
5 changed files with 376 additions and 276 deletions
|
@ -135,16 +135,21 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
|
|||
{
|
||||
pthread_t th;
|
||||
int success;
|
||||
#ifdef THREAD_STACK_SIZE
|
||||
#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
|
||||
pthread_attr_t attrs;
|
||||
#endif
|
||||
dprintf(("PyThread_start_new_thread called\n"));
|
||||
if (!initialized)
|
||||
PyThread_init_thread();
|
||||
|
||||
#ifdef THREAD_STACK_SIZE
|
||||
#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
|
||||
pthread_attr_init(&attrs);
|
||||
#endif
|
||||
#ifdef THREAD_STACK_SIZE
|
||||
pthread_attr_setstacksize(&attrs, THREAD_STACK_SIZE);
|
||||
#endif
|
||||
#ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
|
||||
pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
|
||||
#endif
|
||||
success = pthread_create(&th,
|
||||
#if defined(PY_PTHREAD_D4)
|
||||
|
@ -160,7 +165,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
|
|||
func,
|
||||
arg
|
||||
#elif defined(PY_PTHREAD_STD)
|
||||
#ifdef THREAD_STACK_SIZE
|
||||
#if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
|
||||
&attrs,
|
||||
#else
|
||||
(pthread_attr_t*)NULL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue