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]

 



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();
}

jiffies is a kernel variable that gets incremented every scheduler tick.

Regards,
Konstantyn


-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Karthik Subramanian
Sent: Monday, November 29, 2004 9:55 PM
To: kernelnewbies
Subject: Re: How do I make a kernel module "sleep" without affecting other
kernel modules?

Thanks Greg, but it looks like the version of the kernel I'm using
doesn't have msleep.

I realize that I should've been a little more specific: 

I'm using the linux kernel version 2.4.18-14.

What I need to do is this - one kernel module has to wait for another
kernel module to do some processing and set a flag. So I'm trying to
get the listening kernel module to sleep for some time.

Am I doing this the right way at all,  or is there a better way of doing
this?

Thanks!

Regards,
Karthik.


On Mon, 29 Nov 2004 16:48:27 -0800, Greg KH <greg@xxxxxxxxx> wrote:
> On Fri, Nov 26, 2004 at 09:27:09AM +0530, Karthik Subramanian wrote:
> > Hi Folks,
> >
> > I'm a *total* newbie, and would appreciate any help I get!
> >
> > I have a kernel module, and I need to make it suspend its execution
> > for a specified period of time (say 10 seconds).  How do I do this?
> 
> Did you look at the msleep() function?
> 
> That should do what you want.
> 
> Good luck,
> 
> greg k-h
> 


-- 
There are things known and things unknown, in between lie the Doors

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/

--
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