From owner-freebsd-arch Mon May 22 1:26: 3 2000 Delivered-To: freebsd-arch@freebsd.org Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by hub.freebsd.org (Postfix) with ESMTP id D1D2D37C13D for ; Mon, 22 May 2000 01:25:48 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from nlsys.demon.co.uk ([158.152.125.33] helo=herring.nlsystems.com) by anchor-post-30.mail.demon.net with esmtp (Exim 2.12 #1) id 12tnWz-000FEZ-0U; Mon, 22 May 2000 09:25:46 +0100 Received: from salmon.nlsystems.com (salmon.nlsystems.com [10.0.0.3]) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id JAA96525; Mon, 22 May 2000 09:28:55 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Mon, 22 May 2000 09:28:41 +0100 (BST) From: Doug Rabson To: "C. Stephen Gunn" Cc: arch@FreeBSD.ORG Subject: Re: A new api for asynchronous task execution (3) In-Reply-To: <20000521123546.A7522@waterspout.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 21 May 2000, C. Stephen Gunn wrote: > > Doug & -arch, > > First let me say that your taskqueue stuff looks great. In looking > over the API, and your implementation, I have some questions. > > First, as someone else already pointed out, you were calling the > tasks at splhigh(). While you fixed this in taskqueue_run(), the > call to taskqueue_run() inside taskqueue_free() runs at splhigh(). > This is probably intended to avoid new tasks being queued by > interrupt handlers while disposing of the queue. > > What about an intelligent (or stupid) task that tries to queue > itself onto the queue again? This isn't an uncommon mechanism for > periodic tasks. > > Having taskqueue_enqueue() return an error if we're in the process > of deleting this queue could address this problem. It's a rare > case, since I don't foresee the creation/deletion of queues happening > with much frequency. The tasks called via taskqueue_free() should probably not be called at splhigh(). I think the right solution is to put the queue into a 'closing' state and return errors from taskqueue_enqueue as you suggest. > > I was also wondering about the ta_context mechanism. I initially > thought you were trying to hide the task structure behind the API > so that binary-only modules (and the like) would be tolerant of > changes in the structure. This is probably not the case, since > task_enqueue() takes a struct *task. > > Would there be any benefit to simply passing the task structure to > the task_fn()? > > Tasks could then define a struct with a struct task at the top. > This mechanism is certainly used lots of placed in the kernel. > I know there's little real difference. I guess my questions is > whether the rest of the kernel sets any precident. I'm not particularly trying to hide the task structure. The caller is reponsible for allocating the task anyway. The intention of having a context value to pass to the function is flexibility. If you just pass the task pointer, then you force users to lay their structures out in a certain way which may not be possible in general. Adding a pointer to the structure is a pretty low-cost way of allowing the user to do anything they need. > > Next, I was wondering if it made any sense to put a pointer to the > taskqueue in the task structure. This would make it easier for > a task_fn() to re-queue itself. Or should we doucment that > practice as inappropriate. I thought about this and decided against it. I have some vague plans to extend the system to allow several queues with the same name. This would change taskqueue_find() to cycle through the queues round-robin fashion and would be used for SMP load balancing. > > Finally, are you planning to call taskqueue_free() on all the queues > at system shutdown? This is obviously outside the scope of the > code you'd provided, I was just wondering. Probably not. -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 20 8442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message