diff options
author | Guido van Rossum <guido@python.org> | 2001-09-10 14:10:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-10 14:10:54 (GMT) |
commit | d0b69eceb446ac7176f96c3849c6997ec4ce134f (patch) | |
tree | 4359c27de8896645e053c1d673a5829a0f05f7cc /Python/thread_pthread.h | |
parent | 47f40343b304cbd92dec796cdb2b647743a95c01 (diff) | |
download | cpython-d0b69eceb446ac7176f96c3849c6997ec4ce134f.zip cpython-d0b69eceb446ac7176f96c3849c6997ec4ce134f.tar.gz cpython-d0b69eceb446ac7176f96c3849c6997ec4ce134f.tar.bz2 |
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.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r-- | Python/thread_pthread.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 6910ccb..26120d6 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -135,17 +135,22 @@ 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) pthread_attr_default, @@ -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, |