From: michi1@michaelblizek.twilightparadox.com (michi1 at michaelblizek.twilightparadox.com)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Generic I/O
Date: Tue, 15 Nov 2011 19:13:21 +0100 [thread overview]
Message-ID: <20111115181321.GA2219@grml> (raw)
In-Reply-To: <4EC168C2.8090402@gnukai.com>
Hi!
On 12:15 Mon 14 Nov , Kai Meyer wrote:
...
> My
> caller function has an atomic_t value that I set equal to the number of
> bios I want to submit. Then I pass a pointer to that atomic_t around to
> each of the bios which decrement it in the endio function for that bio.
>
> Then the caller does this:
> while(atomic_read(numbios) > 0)
> msleep(1);
>
> I'm finding the msleep(1) is a really really really long time,
> relatively. It seems to work ok if I just have an empty loop, but it
> also seems to me like I'm re-inventing a wheel here.
...
You might want to take a look at wait queues (the kernel equivalent to pthread
"condidions"). Basically you instead of calling msleep(), you call
wait_event(). In the function which decrements numbios, you check whether it
is 0 and if so call wake_up().
-Michi
--
programing a layer 3+4 network protocol for mesh networks
see http://michaelblizek.twilightparadox.com
next prev parent reply other threads:[~2011-11-15 18:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-14 19:15 Generic I/O Kai Meyer
2011-11-15 18:13 ` michi1 at michaelblizek.twilightparadox.com [this message]
2011-11-15 18:40 ` Kai Meyer
2011-11-15 19:12 ` michi1 at michaelblizek.twilightparadox.com
-- strict thread matches above, loose matches on Subject: below --
2011-10-31 16:24 generic I/O Kai Meyer
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=20111115181321.GA2219@grml \
--to=michi1@michaelblizek.twilightparadox.com \
--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.