From d0b69eceb446ac7176f96c3849c6997ec4ce134f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 10 Sep 2001 14:10:54 +0000 Subject: 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. --- Python/thread_pthread.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Python') diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 6910ccba1e..26120d6886 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -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, -- cgit v1.2.1