From owner-freebsd-arch Wed Jul 10 15:38:46 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 C9E2037B400; Wed, 10 Jul 2002 15:38:43 -0700 (PDT) Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net [207.217.120.62]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6222543E31; Wed, 10 Jul 2002 15:38:43 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0451.cvx22-bradley.dialup.earthlink.net ([209.179.199.196] helo=mindspring.com) by snipe.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17SQ6Z-000114-00; Wed, 10 Jul 2002 15:38:39 -0700 Message-ID: <3D2CB73E.670D80C8@mindspring.com> Date: Wed, 10 Jul 2002 15:37:50 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Archie Cobbs Cc: John Baldwin , davidx@viasoft.com.cn, freebsd-arch@FreeBSD.org, julian@elischer.org Subject: Re: Timeout and SMP race References: <200207102127.g6ALRl329601@arch20m.dellroad.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Archie Cobbs wrote: > 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. This depends on whether you mutex is local to the timer only, or if it has other uses. There is also an order of operation race, if you can be preempted between the cancel and the start. 8-). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message