[Python-checkins] CVS: python/dist/src/Python thread_pthread.h,2.31,2.32

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 10 Sep 2001 07:10:56 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv4323/Python

Modified Files:
	thread_pthread.h 
Log Message:
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.



Index: thread_pthread.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v
retrieving revision 2.31
retrieving revision 2.32
diff -C2 -d -r2.31 -r2.32
*** thread_pthread.h	2001/08/29 15:24:53	2.31
--- thread_pthread.h	2001/09/10 14:10:54	2.32
***************
*** 136,140 ****
  	pthread_t th;
  	int success;
! #ifdef THREAD_STACK_SIZE
  	pthread_attr_t attrs;
  #endif
--- 136,140 ----
  	pthread_t th;
  	int success;
! #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
  	pthread_attr_t attrs;
  #endif
***************
*** 143,150 ****
  		PyThread_init_thread();
  
! #ifdef THREAD_STACK_SIZE
  	pthread_attr_init(&attrs);
  	pthread_attr_setstacksize(&attrs, THREAD_STACK_SIZE);
  #endif
  	success = pthread_create(&th, 
  #if defined(PY_PTHREAD_D4)
--- 143,155 ----
  		PyThread_init_thread();
  
! #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)
***************
*** 161,165 ****
  				 arg
  #elif defined(PY_PTHREAD_STD)
! #ifdef THREAD_STACK_SIZE
  				 &attrs,
  #else
--- 166,170 ----
  				 arg
  #elif defined(PY_PTHREAD_STD)
! #if defined(THREAD_STACK_SIZE) || defined(PTHREAD_SYSTEM_SCHED_SUPPORTED)
  				 &attrs,
  #else