All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Linnanvuori <mattilinnanvuori@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: Do not deprecate binary semaphore or do allow mutex in software interrupt contexts
Date: Tue, 11 Sep 2007 09:20:23 -0700 (PDT)	[thread overview]
Message-ID: <36061.50670.qm@web52002.mail.re2.yahoo.com> (raw)

 Arjan van de Ven:
> what do you do if the trylock fails?

Just do not read the status variable now but modify the timer to run later.

> to be honest, the scenario describe really smells of broken locking, in
> fact it really sounds like it wants to use spinlocks instead 

No, I don't think it is broken.
Spinlocks can be used, but I don't see them being obviously better in all cases.
If access takes a long time, it is better to sleep during it.
And if you sleep, you might just end up creating a new mutex implementation with a spinlock.

Alan Cox:
> For polling and timer based code its often simpler to do
>
>    del_timer_sync(&my_timer);
>    FrobStuff
>    add_timer(&my_timer);
>
> especially if "FrobStuff" is likely to change when you next need to poll.

In the scenario I presented, the timer modifies itself to run later.
Therefore, simply calling del_timer_sync is not enough but you have to set an atomic variable to prevent the timer from adding itself again.
Again, you end up creating a new mutex implementation, which is not good.




       __________________________________ 
Yahoo! Clever - Der einfachste Weg, Fragen zu stellen und Wissenswertes mit Anderen zu teilen. www.yahoo.de/clever


             reply	other threads:[~2007-09-11 16:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-11 16:20 Matti Linnanvuori [this message]
2007-09-11 16:50 ` Do not deprecate binary semaphore or do allow mutex in software interrupt contexts Peter Zijlstra
2007-09-11 18:22 ` Arjan van de Ven
  -- strict thread matches above, loose matches on Subject: below --
2007-09-12  5:39 Matti Linnanvuori
2007-09-11 17:29 Matti Linnanvuori
2007-09-11 19:22 ` Arjan van de Ven
2007-09-11 13:20 Matti Linnanvuori
2007-09-11 14:36 ` Arjan van de Ven
2007-09-11 13:56   ` Alan Cox

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=36061.50670.qm@web52002.mail.re2.yahoo.com \
    --to=mattilinnanvuori@yahoo.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 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.