* How to make a kernel thread sleep for a short amount of time?
@ 2002-07-04 21:22 Ben Greear
2002-07-04 21:36 ` bert hubert
2002-07-18 14:39 ` Corey Minyard
0 siblings, 2 replies; 3+ messages in thread
From: Ben Greear @ 2002-07-04 21:22 UTC (permalink / raw)
To: linux-kernel
I am re-working the net/core/pktgen code to be a kernel thread.
It is basically working, but I am having trouble making the thread
efficiently sleep for durations in the milisecond and micro-second range.
I have looked at the udelay and mdelay methods, but they busy
wait.
I do not need absolute real-time precision, so if I ask the thread
to sleep for 100 micro-seconds, it is not a big deal if it does
not wake up for 5000us. On average, it should be very close to 100us.
I believe the answer may be to use some sort of timer and have my
thread sleep on this timer, but I cannot find any examples or
documentation on how to do this on the web.
If anyone can point me to some example code or documentation, I
would appreciate it.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com> <Ben_Greear AT excite.com>
President of Candela Technologies Inc http://www.candelatech.com
ScryMUD: http://scry.wanfear.com http://scry.wanfear.com/~greear
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to make a kernel thread sleep for a short amount of time?
2002-07-04 21:22 How to make a kernel thread sleep for a short amount of time? Ben Greear
@ 2002-07-04 21:36 ` bert hubert
2002-07-18 14:39 ` Corey Minyard
1 sibling, 0 replies; 3+ messages in thread
From: bert hubert @ 2002-07-04 21:36 UTC (permalink / raw)
To: Ben Greear; +Cc: linux-kernel
On Thu, Jul 04, 2002 at 02:22:29PM -0700, Ben Greear wrote:
> I believe the answer may be to use some sort of timer and have my
> thread sleep on this timer, but I cannot find any examples or
> documentation on how to do this on the web.
The only generally available timer is the timer interrupt, sadly, which
ticks once every 10ms (or soon once every ms, according to Linus' bitkeeper
tree) on i386.
At OLS I was told of the existence of 'firm timers':
http://www.cse.ogi.edu/~luca/firm.html
These might have use in the shaping world too.
Regards,
bert hubert
--
http://www.PowerDNS.com Versatile DNS Software & Services
http://www.tk the dot in .tk
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to make a kernel thread sleep for a short amount of time?
2002-07-04 21:22 How to make a kernel thread sleep for a short amount of time? Ben Greear
2002-07-04 21:36 ` bert hubert
@ 2002-07-18 14:39 ` Corey Minyard
1 sibling, 0 replies; 3+ messages in thread
From: Corey Minyard @ 2002-07-18 14:39 UTC (permalink / raw)
To: Ben Greear; +Cc: linux-kernel
I am using high-res timers
(http://sourceforge.net/projects/high-res-timers) in a driver to do
sub-millisecond timing for a driver I am developing. With high-res
timers, I have some code that looks like:
#ifdef CONFIG_HIGH_RES_TIMERS
/* If the state machine asks for a short delay, then shorten
the timer timeout. */
if (kcs_result == KCS_CALL_WITH_DELAY) {
kcs_timer.sub_expires
+= usec_to_arch_cycles(KCS_SHORT_TIMEOUT_USEC);
while (kcs_timer.sub_expires >= cycles_per_jiffies) {
kcs_timer.expires++;
kcs_timer.sub_expires -= cycles_per_jiffies;
}
} else {
kcs_timer.expires += KCS_TIMEOUT_JIFFIES;
}
#else
kcs_timer.expires += KCS_TIMEOUT_JIFFIES;
#endif
But the high-res timers are not in the kernel right now, it's a patch
you have to add, and the user has to have it configured.
-Corey
Ben Greear wrote:
> I am re-working the net/core/pktgen code to be a kernel thread.
>
> It is basically working, but I am having trouble making the thread
> efficiently sleep for durations in the milisecond and micro-second range.
>
> I have looked at the udelay and mdelay methods, but they busy
> wait.
>
> I do not need absolute real-time precision, so if I ask the thread
> to sleep for 100 micro-seconds, it is not a big deal if it does
> not wake up for 5000us. On average, it should be very close to 100us.
>
> I believe the answer may be to use some sort of timer and have my
> thread sleep on this timer, but I cannot find any examples or
> documentation on how to do this on the web.
>
> If anyone can point me to some example code or documentation, I
> would appreciate it.
>
> Thanks,
> Ben
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-07-18 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-04 21:22 How to make a kernel thread sleep for a short amount of time? Ben Greear
2002-07-04 21:36 ` bert hubert
2002-07-18 14:39 ` Corey Minyard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox