From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Florin Iucha" <florin@iucha.net>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: "upping" a semaphore from interrupt context?
Date: Fri, 22 Jun 2007 23:20:04 +0530 [thread overview]
Message-ID: <a781481a0706221050y6c7adba6l27d11e35db69fc31@mail.gmail.com> (raw)
In-Reply-To: <20070622173839.GB8398@iucha.net>
Hi Florin,
On 6/22/07, Florin Iucha <florin@iucha.net> wrote:
> Hello,
>
> I am writing a USB driver for some custom hardware, and I need to
> synchronize between the user-space and the USB subsystem. Can I
> create a semaphore and "down" it in the reader then "up" it in the
> completion handler?
It's not exactly clear from your description what you are
"synchronizing" exactly ... if there is some shared data you want
accessed from process as well as interrupt context, the (only) safe
primitives to use are spin_lock_irqsave / spin_unlock_irqrestore.
If you simply want the process context task to block _till_ it receives
some kind of notification that some other job has been completed
(seems to be from interrupt context in your case from your
description) than I suspect "struct completion" and associated
primitives are what you are looking for.
> I know the completion handler runs in interrupt context so you are not
> allowed to acquire any semaphores: but can you release them? Will the
> waiting tasks wake up after the handler and its caller returned - IOW
> will the waking up task run in interrupt context as well?
The waiting task (say if it was blocked at wait_for_completion) would
continue to execute in the same context it was from that point onwards.
> This is with Linux 2.4 (if it makes a difference).
Whoa, it does, I would expect. I'm not sure completion handlers
exist in 2.4? If they do, they're the way to go. If not, sorry, I'm not
well versed with the 2.4 kernel at all.
Satyam
prev parent reply other threads:[~2007-06-22 17:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-22 17:38 Florin Iucha
2007-06-22 17:34 ` Arnd Bergmann
2007-06-23 11:52 ` Robert P. J. Day
2007-06-23 12:02 ` Arnd Bergmann
2007-06-23 12:06 ` Robert P. J. Day
2007-06-23 15:42 ` Satyam Sharma
2007-06-23 15:52 ` Oliver Neukum
2007-06-23 17:02 ` Satyam Sharma
2007-06-23 16:11 ` Robert P. J. Day
2007-06-23 17:16 ` Satyam Sharma
2007-06-24 15:25 ` Robert P. J. Day
2007-06-24 16:45 ` Satyam Sharma
2007-06-24 16:59 ` Robert P. J. Day
2007-06-24 18:12 ` Satyam Sharma
2007-06-22 17:50 ` Satyam Sharma [this message]
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=a781481a0706221050y6c7adba6l27d11e35db69fc31@mail.gmail.com \
--to=satyam.sharma@gmail.com \
--cc=florin@iucha.net \
--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
all inboxes | Powered by JetHome®