diff Python/thread_pthread.h @ 19826:8ef456949b76 legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Mon, 10 Sep 2001 14:10:54 +0000
parents 11a758c56027
children c9a212329da6
line wrap: on
line diff
--- a/Python/thread_pthread.h	Mon Sep 10 13:34:12 2001 +0000
+++ b/Python/thread_pthread.h	Mon Sep 10 14:10:54 2001 +0000
@@ -135,17 +135,22 @@
 {
 	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 @@
 				 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,