From owner-freebsd-arch Wed Jul 10 14:45: 7 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 73C2637B400; Wed, 10 Jul 2002 14:45:05 -0700 (PDT) Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id DA18843E52; Wed, 10 Jul 2002 14:45:04 -0700 (PDT) (envelope-from archie@dellroad.org) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id OAA69955; Wed, 10 Jul 2002 14:28:20 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g6ALRl329601; Wed, 10 Jul 2002 14:27:47 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200207102127.g6ALRl329601@arch20m.dellroad.org> Subject: Re: Timeout and SMP race In-Reply-To: <3D2C9E8A.8D7657E7@mindspring.com> "from Terry Lambert at Jul 10, 2002 01:52:26 pm" To: Terry Lambert Date: Wed, 10 Jul 2002 14:27:47 -0700 (PDT) Cc: Archie Cobbs , John Baldwin , davidx@viasoft.com.cn, freebsd-arch@FreeBSD.org, julian@elischer.org X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Terry Lambert writes: > > FWIW, here is an API I've used before. This handles all race > > conditions and the 'other thread' question. > > I like this timer API. > > You need to add a timer_modify_interval (or something similar), so > that intervals can be changed without having to destroy and recreate > the timer, though, to avoid another potential race condition. There's no race condition there. You can just do this to 'reset' a timer: timer_cancel(&foo->timer); timer_start(&foo->timer, ...); Your timer_modify_interval() would just be an optimization of this. I forgot to mention that timer_cancel() does nothing if *handlep == NULL. -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message