Re: How do I make a kernel module "sleep" without affecting other kernel modules?

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

 



On Tue, Nov 30, 2004 at 09:25:11AM -0500, Prokopenko, Konstantyn wrote:
> Hello,
> 
> If no external event is there to interrupt your module, you can implement
> simple function to sleep number of ticks:
> 
> Note: Each tick = 1000/HZ where HZ = scheduler frequency (defined in
> asm/param.h)
> 
> void dev_wait(unsigned long ticks)
> {
>     unsigned long awake = jiffies+ticks;
> 
>     current->policy |= SCHED_YIELD
>     while(awake > jiffies)
>         schedule();
> }

No, what happens when jiffies wraps, directly comparing things with
jiffies is not good, please use the wrapper functions for that.

Just use schedule_timeout() if you want to do something like this.

thanks,

greg k-h

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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