From: Wayne Cuddy <wcuddy@crb-web.com>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Synchronization Techniques in 2.2 Kernel
Date: Thu, 27 Sep 2001 14:12:38 -0500 [thread overview]
Message-ID: <20010927141238.E5125@crb-web.com> (raw)
I am working on a custom driver for a project at work. We are working with
Debian 2.2, the code is compiled as a module. At this time I am not able to
switch our project to the 2.4.x kernels so I require a solution using 2.2.x.
The driver has the capability to control many cards at once. It is written
such that when the read system call is invoked data available on any card is
returned, so we don't use a separate file descriptor for each card.
I believe I have a "race condition" in the drivers read method when blocking
I/O is used and there is no data in the DMA buffers. Here is some very basic
pseudo code for the driver's read method:
driver_read()
{
start_card = x;
while(1)
{
if(card_has_data(x))
return data;
x = next_card(x);
if(start_card == x)
{
/* none of the cards has any data, sleep
* on a wait queue */
interruptible_sleep_on.....
}
}
}
After the device performs the DMA it will wake the driver via the interrupt
handler. The problem is how to handle the situation where the driver checks a
card for data, no data is available and it moves on to the next card. While
checking the rest of the cards data may arrive on the 1st card, the interrupt
handler will fire and complete before the driver goes to sleep on the wait
queue.
If I understand wait_queues correctly the process has to be sleeping before a
wake_up call will have any effect (I.E. they are not queued). Can this be
worked around with semaphores or some other method? I am open to ideas here.
Any and all help is appreciated.
Wayne
next reply other threads:[~2001-09-27 18:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-09-27 19:12 Wayne Cuddy [this message]
2001-09-27 20:34 ` Synchronization Techniques in 2.2 Kernel Brian Strand
2001-09-27 21:07 ` David Woodhouse
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=20010927141238.E5125@crb-web.com \
--to=wcuddy@crb-web.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox