[Gllug] Clock( ) function in C

dudes dudes akam123 at hotmail.co.uk
Tue Sep 20 20:57:56 UTC 2011


thanks, timer_settime()did the trick :)

> From: nix at esperi.org.uk
> To: gllug at gllug.org.uk
> Date: Tue, 20 Sep 2011 18:17:43 +0100
> Subject: Re: [Gllug] Clock( ) function in C
> 
> On 20 Sep 2011, Tethys . outgrape:
> 
> > On Tue, Sep 20, 2011 at 3:43 PM, dudes dudes <akam123 at hotmail.co.uk> wrote:
> >
> >> I’m trying to use clock() function (time.h) in milliseconds, but not CPU
> >> based. For example do something (some codes) for 5 milliseconds and when it
> >> is exactly 5 millisecond, then exit();
> >
> > You can't do that with standard Linux. All you can do is say "this
> > will run for at least 5 milliseconds". If you need precise accuracy,
> > in that it must be *exactly* 5ms, you need to use one of the realtime
> > Linux variants.
> 
> And you wouldn't use clock() for that anyway, you'd use getrusage(), or
> timer_gettime() on a timer created with CLOCK_PROCESS_CPUTIME_ID or
> CLOCK_THREAD_CPUTIME_ID, possibly passed to a timerfd to enable you to
> get interrupt-driven notification of its expiry, or something like that.
> 
> -- 
> NULL && (void)
> --
> Gllug mailing list  -  Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20110920/c62502b2/attachment.html>
-------------- next part --------------
--
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list