On Wed, Jan 20, 2016 at 11:50:24AM +0530, Anupam Kapoor wrote: > > >>>>> [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 */ that should be a unsigned long tout = msecs_to_jiffies(user.timeout); to ensure that all corner cases are properly handled, e.g. for HZ=100 the above would be 0 for user.timeout < 10 which is probably not what you want. > | 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. > that would still have the same limitation with resepct to time granuarlity and as Documentation/timers/ if you really need very short delays then you will need to resort to hrtimers (and thus be to some extent config dependent) usleep_range(min, max) is the prefered interface in that case. thx! hofrat _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies