From dev-return-14126-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Wed Apr 27 12:09:56 2005 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 35684 invoked from network); 27 Apr 2005 12:09:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Apr 2005 12:09:56 -0000 Received: (qmail 86461 invoked by uid 500); 27 Apr 2005 12:10:36 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 86204 invoked by uid 500); 27 Apr 2005 12:10:32 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 86148 invoked by uid 99); 27 Apr 2005 12:10:29 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=HTML_30_40,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from bigipbgp.itri.org.tw (HELO maillog.itri.org.tw) (61.61.254.20) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 27 Apr 2005 05:10:28 -0700 Received: from mail.itri.org.tw (mail [140.96.157.2]) by maillog.itri.org.tw (8.11.6+Sun/8.11.6) with ESMTP id j3RCCMf18901 for ; Wed, 27 Apr 2005 20:12:22 +0800 (CST) Received: from ms4.itri.org.tw ([140.96.151.44]) by mail.itri.org.tw (8.11.6+Sun/8.11.6) with ESMTP id j3RC0dB28854 for ; Wed, 27 Apr 2005 20:00:39 +0800 (CST) Received: from [140.96.83.35] ([140.96.254.153]) by ms4.itri.org.tw (Lotus Domino Release 5.0.13a) with ESMTP id 2005042720092848:5676 ; Wed, 27 Apr 2005 20:09:28 +0800 Message-ID: <426F80F9.5080203@itri.org.tw> Date: Wed, 27 Apr 2005 20:09:29 +0800 From: Cheng Po-wen Organization: W100, CCL/ITRI User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@apr.apache.org Subject: some questions about thread creation and thread pool X-MIMETrack: Itemize by SMTP Server on MS4/ITRI(Release 5.0.13a |April 8, 2004) at 2005-04-27 08:09:28 PM, Serialize by Router on MS4/ITRI(Release 5.0.13a |April 8, 2004) at 2005-04-27 08:09:29 PM, Serialize complete at 2005-04-27 08:09:29 PM Content-Type: multipart/alternative; boundary="------------000601090804060002090508" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------000601090804060002090508 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=Big5 Hi, I try to write a thread pool implementation on top of Apache APR, I meet some problems: 1. apr_thread_create (apr_thread_t **new_thread, ....., apr_pool_t *cont) I've trace the source code about this function, internally, it uses "count" to allocate the memory for apr_thread_t, & pthread_t like : (*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t)); (*new)->td = (pthread_t *)apr_pcalloc(pool, sizeof(pthread_t)); and it uses "count" as parent pool to create a new pool for this thread, when "child threads" exit, they will automatically destroy their own pool, but the questions is this will still leave the apr_thread_t, & pthread_t memory allocated in the parent pool "dangling". so,.... can I solve the "dangling" memory problem when creating Thread Pool on top of APR? because threads are created & exit (if nessary) all the time in my implementatin. THANX -- Sting, Cheng Po-wen(¾G³Õ¤å) Phone : 886-3-5914545 Fax : 886-3-5820085 E-Mail : sting@itri.org.tw Internet Software Technology Division(W100) Computer & Communication Research Lab. / ITRI --------------000601090804060002090508 Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=Big5 Hi,

I try to write a thread pool implementation on top of Apache APR,
I meet some problems:

1. apr_thread_create (apr_thread_t **new_thread, ....., apr_pool_t *cont)

I've trace the source code about this function,
internally, it uses "count" to allocate the memory for  apr_thread_t, & pthread_t
like :

(*new) = (apr_thread_t *)apr_pcalloc(pool, sizeof(apr_thread_t));
(*new)->td = (pthread_t *)apr_pcalloc(pool, sizeof(pthread_t));

and it uses "count" as parent pool to create a new pool for this thread,

when "child threads" exit, they will automatically destroy their own pool,
but the questions is this will still leave the apr_thread_t, & pthread_t
memory allocated in the parent pool "dangling".

so,....
can I solve the "dangling" memory problem when creating Thread Pool on top of APR?
because threads are created & exit (if nessary) all the time in my implementatin.

THANX
-- 
Sting, Cheng Po-wen(¾G³Õ¤å)
Phone :  886-3-5914545  Fax : 886-3-5820085
E-Mail : sting@itri.org.tw

Internet Software Technology Division(W100)
Computer & Communication Research Lab. / ITRI
--------------000601090804060002090508--