[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Multi-threaded slapd on AIX 4.2.1



At 09:21 30/06/99 -0700, you wrote:
> ...
>What threading features did configure detect?  Specifically,
>did it detect Pthread draft4 or final compatible threading?
>Did it detect sched_yield and/or pthread_yield()?
>If final was detected, does your system have sched_yield?
>Is the detection consistent with AIX's threading implementation?
>
>I can infer some of this from your patch... but the above would
>be useful in general.

configure detected pthread final compatible (which looks weird to me) and
pthread_yield. Here's what configure said exactly :

...
checking for pthread.h... yes
checking for sched.h... no
checking POSIX thread version... final
checking for LinuxThreads... no
checking for pthread_create... yes
checking for sched_yield... no
checking for pthread_yield... yes
checking for pthread_kill... yes
checking for pthread_detach with <pthread.h>... yes
checking for pthread_setconcurrency... no
checking for pthread_getconcurrency... no
checking for thr_setconcurrency... no
checking for thr_getconcurrency... no
checking if pthread_create() works... yes
checking if select yields when using pthreads... yes
checking for thread specific errno... yes
...

sched_yield does not seem to be supported on AIX 4.2.1.

>>2) By default, threads are created "detached" on AIX 4.2.1. To create them
>>"undetached" (or "joinable"), an explicit parameter must be passed to
>>pthread_create :
>
>Yiks!  This will break most every thread application that relies on
>threads being joinable by default (as required by the standard).
>Looks like it's fixed in AIX 4.3.

That's why I doubt AIX 4.2.1 provides pthread final...

>I also noticed that you used a flag PTHREAD_CREATE_UNDETACHED.
>Does AIX not have PTHREAD_CREATE_JOINABLE?

No it only has PTHREAD_CREATE_UNDETACHED.

>Or, is this a problem with the pthread_create call using NULL
>instead of the Pthread draft4 pthread_attr_default macro.  If

I don't think so : the man page clearly states that if NULL is passed then
the default is used. And the default is explained in pthread_attr_init man
page :
Always :
  Detachstate : PTHREAD_CREATE_DETACHED (Linux gives PTHREAD_CREATE_JOINABLE)
if _POSIX_THREAD_PRIORITY_SCHEDULING is defined :
  Contention-scope : PTHREAD_SCOPE_PROCESS (Linux gives PTHREAD_SCOPE_SYSTEM)
  Inheritsched : PTHREAD_INHERITSCHED (Linux gives PTHREAD_EXPLICIT_SCHED)
  Schedparam : the least favored priority
  Schedpolicy : SCHED_OTHER
if _POSIX_THREAD_ATTR_STACKSIZE is defined :
  Stacksize : PTHREAD_STACK_MIN

>your system was detected as draft4, I'd be curious to whether
>or not using pthread_attribute_default would provide joinable
>threads.   Our devel code uses pthread_attribute_default when
>draft4 is detected.

I'll try to find a way to force draft4 detection and check what happens...
Anyway "pthread_attr_init(&attr);" is supposed to copy pthread_attr_default
to attr and it creates detached threads.

>>The resulting slapd (with the gdbm backend) runs fine and gives a good
>>response time but is subject to huge memory leaks. The same server compiled
>>on a Linux box does not appear to grow (with the gdbm backend again).
>>Neither does the same server compiled on AIX without threads support. Can
>>anybody help?
>
>I suspect pthread_detach() is not detaching the threads...
>resulting in significant resource leakage.

pthread_detach does not even have a "man page" on AIX 4.2.1, so I tried not
using it (it appears only once in the code in ldap_pvt_thread_create) :

if (detach) { pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); }
else { pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_UNDETACHED); }
pthread_create(thread,&attr,...);

This works fine on a small test program (threads are indeed created
detached or joinable as requested) but did not change anything to slapd.

CU,

Frederic.