From: der.herr@hofr.at (Nicholas Mc Guire)
To: kernelnewbies@lists.kernelnewbies.org
Subject: how to use wait_event_interruptible_timeout with less than 1 jiffie timeout?
Date: Wed, 20 Jan 2016 08:25:54 +0000 [thread overview]
Message-ID: <20160120082554.GE13776@osadl.at> (raw)
In-Reply-To: <87d1swsrfb.fsf@fatcat.parallelwireless>
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
next prev parent reply other threads:[~2016-01-20 8:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 19:51 how to use wait_event_interruptible_timeout with less than 1 jiffie timeout? Daniel.
2016-01-20 6:20 ` Anupam Kapoor
2016-01-20 8:25 ` Nicholas Mc Guire [this message]
2016-01-20 13:27 ` Anupam Kapoor
2016-01-20 15:01 ` Nicholas Mc Guire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160120082554.GE13776@osadl.at \
--to=der.herr@hofr.at \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.