From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261782AbVGOBSL (ORCPT ); Thu, 14 Jul 2005 21:18:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261767AbVGOBSL (ORCPT ); Thu, 14 Jul 2005 21:18:11 -0400 Received: from tomts36-srv.bellnexxia.net ([209.226.175.93]:55232 "EHLO tomts36-srv.bellnexxia.net") by vger.kernel.org with ESMTP id S261782AbVGOBR4 (ORCPT ); Thu, 14 Jul 2005 21:17:56 -0400 Subject: Re: [PATCH] i386: Selectable Frequency of the Timer Interrupt From: Eric St-Laurent To: Alan Cox Cc: Linus Torvalds , Vojtech Pavlik , Arjan van de Ven , Lee Revell , dean gaudet , Chris Wedgwood , Andrew Morton , "Brown, Len" , dtor_core@ameritech.net, david.lang@digitalinsight.com, davidsen@tmr.com, kernel@kolivas.org, Linux Kernel Mailing List , mbligh@mbligh.org, diegocg@gmail.com, azarah@nosferatu.za.org, christoph@lameter.com In-Reply-To: <1121380637.3747.10.camel@localhost.localdomain> References: <1121286258.4435.98.camel@mindpipe> <20050713134857.354e697c.akpm@osdl.org> <20050713211650.GA12127@taniwha.stupidest.org> <20050714005106.GA16085@taniwha.stupidest.org> <1121304825.4435.126.camel@mindpipe> <1121326938.3967.12.camel@laptopd505.fenrus.org> <20050714121340.GA1072@ucw.cz> <1121380637.3747.10.camel@localhost.localdomain> Content-Type: text/plain Date: Thu, 14 Jul 2005 21:17:43 -0400 Message-Id: <1121390263.7934.4.camel@orbiter> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2005-07-14 at 23:37 +0100, Alan Cox wrote: > In actual fact you also want to fix users of > > while(time_before(foo, jiffies)) { whack(mole); } > > to become > > init_timeout(&timeout); > timeout.expires = jiffies + n > add_timeout(&timeout); > while(!timeout_expired(&timeout)) {} > > Which is a trivial wrapper around timers as we have them now Or something like this: struct timeout_timer { unsigned long expires; }; static inline void timeout_set(struct timeout_timer *timer, unsigned int msecs) { timer->expires = jiffies + msecs_to_jiffies(msecs); } static inline int timeout_expired(struct timeout_timer *timer) { return (time_after(jiffies, timer->expires)); } It provides a nice API for relative timeouts without adding overhead. - Eric St-Laurent