From owner-freebsd-threads@FreeBSD.ORG Tue Nov 30 07:56:13 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86E95106564A for ; Tue, 30 Nov 2010 07:56:13 +0000 (UTC) (envelope-from bounces@nabble.com) Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by mx1.freebsd.org (Postfix) with ESMTP id 648C28FC08 for ; Tue, 30 Nov 2010 07:56:13 +0000 (UTC) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1PNKo1-0003zf-LH for freebsd-threads@freebsd.org; Mon, 29 Nov 2010 23:39:17 -0800 Message-ID: <30337545.post@talk.nabble.com> Date: Mon, 29 Nov 2010 23:39:17 -0800 (PST) From: p4ddy To: freebsd-threads@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: prdpsbhat@gmail.com X-Mailman-Approved-At: Tue, 30 Nov 2010 12:09:27 +0000 Subject: Creating thread dynamically in a thread pool X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2010 07:56:13 -0000 Hi all, Here is the story. I m handling threads for some server. maxThreadPoolSize is given as 1000 but obviously creating 1000 threads not only takes time but also huge resources. So am thinking of creating threads dynamically for the thread pool. Initially say 100 threads will be created and based on certain factors, more number of threads will be created and added to the pool. As I m new to thread pooling, i have certain doubts: 1. how to determine initial number of threads? currently i have set it to 100 2. how to determine when to create next batch of threads? currently i m creating another batch of threads as soon as the number of active threads reaches 70% of the total threads. 3. what should be the batch size? currently i have set it to 100. so with every batch, 100 threads will be added to the pool 4. another doubt is regarding memory allocation. currently i m allocating memory to all the 1000 threads initially but threads are getting created only when there is a requirement. Is this good? or should i allocate memory dynamically too? Hope to get some answers/opinions :) Thanks in advance. -- View this message in context: http://old.nabble.com/Creating-thread-dynamically-in-a-thread-pool-tp30337545p30337545.html Sent from the freebsd-threads mailing list archive at Nabble.com.