From owner-freebsd-hackers@FreeBSD.ORG Fri Jul 23 21:13:47 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A51916A4CE for ; Fri, 23 Jul 2004 21:13:47 +0000 (GMT) Received: from mail008.syd.optusnet.com.au (mail008.syd.optusnet.com.au [211.29.132.212]) by mx1.FreeBSD.org (Postfix) with ESMTP id 430C043D2D for ; Fri, 23 Jul 2004 21:13:46 +0000 (GMT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (c211-30-75-229.belrs2.nsw.optusnet.com.au [211.30.75.229]) i6NLDgN25980; Sat, 24 Jul 2004 07:13:42 +1000 Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])i6NLDfVd014619; Sat, 24 Jul 2004 07:13:42 +1000 (EST) (envelope-from pjeremy@cirb503493.alcatel.com.au) Received: (from pjeremy@localhost)i6NLDfDO014618; Sat, 24 Jul 2004 07:13:41 +1000 (EST) (envelope-from pjeremy) Date: Sat, 24 Jul 2004 07:13:41 +1000 From: Peter Jeremy To: pradeep reddy punnam Message-ID: <20040723211341.GK3001@cirb503493.alcatel.com.au> References: <20040723005940.18029.qmail@web53410.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040723005940.18029.qmail@web53410.mail.yahoo.com> User-Agent: Mutt/1.4.2i cc: freebsd-hackers@freebsd.org Subject: Re: regarding timeout/untimeout kernel functions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jul 2004 21:13:47 -0000 [Please wrap your mail before 80 columns] On Thu, 2004-Jul-22 17:59:40 -0700, pradeep reddy punnam wrote: > i am working on a project , where i came across a >situation where i need to execute a function when a timer expires >,exactly similar to functionality of the timeout() kernel function How about setitimer(2) and a SIGALRM handler? >but i need this in userland(application), and the execution of the >function is time sensitive, it should be run immediately when timer >expires. What is your definition of "immediately"? Timeouts are rounded to ticks (and FreeBSD has a 1-2 tick slop for various reasons). Once the (rounded) timeout expires, then it's up to the scheduler to actually invoke your timer handler function in line with normal scheduling rules. Overall, it's unlikely that your handler will get called early but it will typically be called about 1 tick late (and there's no upper bound on how late your handler will be invoked if the system is heavily loaded). -- Peter Jeremy