The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Martijn Sipkema <martijn@entmoot.nl>
To: "Peter W. Morreale" <morreale@radiantdata.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: waiting on a condition
Date: Wed, 13 Oct 2004 22:58:43 +0200	[thread overview]
Message-ID: <1097701040.4648.11.camel@localhost.localdomain> (raw)
In-Reply-To: <416D49FF.10003@radiantdata.com>

On Wed, 2004-10-13 at 17:30, Peter W. Morreale wrote:
> Have you looked at the wait_event() family yet?       Adapting that 
> methodolgy might
> suit your needs.

wait_event() seems to be what I was looking for; I don't really like the
condition being an argument.

> I don't know much about preemption yet, however I suspect it would be a 
> bug to allow
> preemption while the spinlock was held.  In other words, you might need 
> to do something like
> 
> disable preemption
> spinlock
> rc = condition
> spin_unlock
> enable preemption
> if (rc)
> ...
> 
> In other words, perform the test on the condition outside of the 
> critical region protected by the spin lock.

Well, that wasn't what I meant exactly. I was looking for a standard
way to wait on a condition so that it would still work when spinlocks
are converted to mutexes such as these new RT patches seem to do;
wait_event() seens to provide this, although I like to POSIX mutex/cond
semantics better.


--ms


P.S. I seem to have been removed from the LKML right after posting
my question (it was the last message I received). Is there something
terribly stupid I may have done? Was the question _that_ stupid?



> -PWM
> 
> 
> Martijn Sipkema wrote:
> 
> >L.S.
> >
> >I'd like to do something similar as can be done using a POSIX condition
> >variable in the kernel, i.e. wait for some condition to become true. The
> >pthread_cond_wait() function allows atomically unlocking a mutex and
> >waiting on a condition. I think I should do something like:
> >(the condition is updated from an interrupt handler)
> >
> >disable interrupts
> >acquire spinlock
> >if condition not satisfied
> >    add task to wait queue
> >    set task to sleep
> >release spinlock
> >restore interrupts
> >schedule
> >
> >Now, this will only work with preemption disabled within the critical
> >section. How would something like this be done whith preemption
> >enabled?
> >
> >
> >--ms
> >
> >
> >
> >
> >-
> >To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> >the body of a message to majordomo@vger.kernel.org
> >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >Please read the FAQ at  http://www.tux.org/lkml/
> >
> >  
> >


  reply	other threads:[~2004-10-13 19:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-13 15:23 waiting on a condition Martijn Sipkema
2004-10-13 14:55 ` Neil Horman
2004-10-13 15:05   ` Duncan Sands
2004-10-13 15:30 ` Peter W. Morreale
2004-10-13 20:58   ` Martijn Sipkema [this message]
2004-10-13 20:58   ` Martijn Sipkema
2004-10-14 15:37     ` Davide Rossetti
2004-10-14 15:49       ` Richard B. Johnson
2004-10-15 13:13     ` Alan Cox
2004-10-13 15:34 ` Christophe Saout

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=1097701040.4648.11.camel@localhost.localdomain \
    --to=martijn@entmoot.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morreale@radiantdata.com \
    /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