how to use wait_event_interruptible_timeout with less than 1 jiffie timeout?
danielhilst at gmail.com
Tue Jan 19 14:51:18 EST 2016
I have some code that convert an timeout comming from userspace (in
ms) to jiffies prior passing to wait_event_interrupitible_timeout().
The code looks like this:
unsigned long tout = user.timeout * HZ / 1000; /* convert from ms to jiffie */
int status = wait_event_interruptible_timeout(wq, cond, tout);
I'm using HZ=100, the known default.
The problem is: with HZ = 100 and user.timeout = 10 I have:
10 * 100 / 1000 = 1,
This means that I can't use timeouts with less than 10ms. Is there any
way to circunvent this without changing HZ value?
Now let me explain why. I have a protocol running on linux that talk
to other embedded systems in an master-slave way. This communication
goes through some RF hardware. The communication is maded by master
transmitting a frame and receiving another frame from slave. The slave
takes about 2 ms to reply, but if the transmitting failed (because the
slave was not listening or because the frame was corrupted while
traveling through the air) the server has to transmit it again. Today
I'm using 10ms as timeout because is the smaller amount that I known
how to use, but if I can decrease this timeout to 2 or 3ms I would
have a better performance in case of failures.
"Do or do not. There is no try"
More information about the Kernelnewbies