Skip to content

Commit 64d8547

Browse files
committed
backport of solaris thread patch, adding PTHREAD_SCOPE_SYSTEM support:
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 is a semi-feature, but makes such a huge difference to the performance of Zope on Solaris that it's worthwhile (well, imho).
1 parent cdf6bfe commit 64d8547

5 files changed

Lines changed: 366 additions & 274 deletions

File tree

‎Python/thread_pthread.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,15 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
129129
pthread_t th;
130130
int success;
131131
dprintf(("PyThread_start_new_thread called\n"));
132+
#ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
133+
pthread_attr_t attrs;
134+
#endif
132135
if (!initialized)
133136
PyThread_init_thread();
137+
#ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
138+
pthread_attr_init(&attrs);
139+
pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
140+
#endif
134141

135142
success = pthread_create(&th,
136143
#if defined(PY_PTHREAD_D4)
@@ -146,7 +153,11 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
146153
func,
147154
arg
148155
#elif defined(PY_PTHREAD_STD)
156+
#ifdef PTHREAD_SYSTEM_SCHED_SUPPORTED
157+
&attrs,
158+
#else
149159
(pthread_attr_t*)NULL,
160+
#endif
150161
(void* (*)(void *))func,
151162
(void *)arg
152163
#endif

‎acconfig.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@
130130
/* The number of bytes in a pthread_t. */
131131
#undef SIZEOF_PTHREAD_T
132132

133+
/* Defined if PTHREAD_SCOPE_SYSTEM supported. */
134+
#undef PTHREAD_SYSTEM_SCHED_SUPPORTED
135+
133136
/* sizeof(void *) */
134137
#undef SIZEOF_VOID_P
135138

‎config.h.in‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
1+
/* config.h.in. Generated automatically from configure.in by autoheader. */
22

33
/* Define if on AIX 3.
44
System headers sometimes define this.
@@ -189,6 +189,9 @@
189189
/* The number of bytes in a pthread_t. */
190190
#undef SIZEOF_PTHREAD_T
191191

192+
/* Defined if PTHREAD_SCOPE_SYSTEM supported. */
193+
#undef PTHREAD_SYSTEM_SCHED_SUPPORTED
194+
192195
/* Define to `int' if <sys/types.h> doesn't define. */
193196
#undef socklen_t
194197

0 commit comments

Comments
 (0)