how to use wait_event_interruptible_timeout with less than 1 jiffie timeout?

Anupam Kapoor anupam.kapoor at gmail.com
Wed Jan 20 01:20:24 EST 2016


>>>>> [2016-01-20T01:21:18+0530]: "Daniel." (Daniel):
,----[ Daniel ]
| 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?
`----
wouldn't msleep_interruptible(...) be a better choice ? as a bonus, it
takes care of jiffies wrapping etc. 

-- 
kind regards
anupam



More information about the Kernelnewbies mailing list