Re: Wait for two clock ticks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Mar 08, 2009 at 02:50:08PM -0500, Asim wrote:
> Thanks guys.
> 
> The msleep solution looks good, but if my device does its work in 1
> micro or nano second then it seems a tad too long to sleep.

What is happening when you need to do this?  Setup time?  Or the normal
"fast path" for the data coming in/to the device?

> Here is
> what I ended up using -
> 
>  {
>    .
>    unsigned long long delta = (cpu/khz/HZ)*2;

How do you know the cpu speed?  It constantly changes on lots of
different processors.

>    unsigned long long _start = 0;
>    unsigned long long _cur = 0;
>    .
> 
>    timeout = rdstcll(start) + delta ;
> 
>    while (1)  {
>      if (_cur < timeout) {
>          rdstcll(_cur);
>      } else {
>         flag_error()
>      }

That's a busy loop, please don't do that, it's not nice unless you
_really_ know what you are doing and what is going on.

Again, be careful about how you try to calculate speed of the cpu, it
constantly changes.

thanks,

greg k-h

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux