From owner-freebsd-threads@FreeBSD.ORG Wed Nov 3 01:32:43 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 38926106566B; Wed, 3 Nov 2010 01:32:43 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 278A18FC0C; Wed, 3 Nov 2010 01:32:43 +0000 (UTC) Received: from xyf.my.dom (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oA31Wflx049186; Wed, 3 Nov 2010 01:32:42 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CD12C3D.3010104@freebsd.org> Date: Wed, 03 Nov 2010 09:32:45 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Julian Elischer References: <4CD03E75.1050302@freebsd.org> <4CD05090.4070404@freebsd.org> In-Reply-To: <4CD05090.4070404@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: Thread ID is reused too quickly 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: Wed, 03 Nov 2010 01:32:43 -0000 Julian Elischer wrote: > On 11/2/10 9:38 AM, David Xu wrote: >> Our kernel thread ID is reused too quickly, is there any way to fix it ? > > we could free them into a holding pool, (an array set up as a ring buffer) > with (say) several hundred slots.. > until the pool fills up we don't actually give any thread-IDs back and > when it fills > up we put the ID we are removing into the head of the queue and give > back the > one that is at the other end of the queue. > > I think it would be very easy to implement.. you might even have a > per-cpu version > if you didn't want a lock or maybe there is a lock already in use we can > hide it under. > > > Julian Yes, we use the ring buffer in thread library to delay a thread structure to be reused too quickly, I agree that kernel can do the same thing. :-)