From: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
To: Larry Finger <larry.finger@lwfinger.net>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: Question regarding mutex locking
Date: Wed, 28 Nov 2007 16:00:55 +0100 [thread overview]
Message-ID: <20071128150055.GK20238@traven> (raw)
In-Reply-To: <474D7F5B.9090008@lwfinger.net>
El Wed, Nov 28, 2007 at 08:46:51AM -0600 Larry Finger ha dit:
> Matthias Kaehlcke wrote:
> > El Tue, Nov 27, 2007 at 10:37:00PM -0600 Larry Finger ha dit:
> >
> >> If a particular routine needs to lock a mutex, but it may be entered with that mutex already locked,
> >> would the following code be SMP safe?
> >>
> >> hold_lock = mutex_trylock()
> >>
> >> ...
> >>
> >> if (hold_lock)
> >> mutex_unlock()
> >
> > this is wont work, a mutex must not be released from another
> > context than the one that acquired it.
>
> I thought that mutex_trylock() returned 1 if it got the lock and 0 if not. If that is true, wouldn't
> the if statement only unlock if the lock was obtained in this routine?
you're right, sorry i read to fast and interpreted that you want to
release the mutex in any case
--
Matthias Kaehlcke
Linux Application Developer
Barcelona
You must have a plan. If you don't have a plan,
you'll become part of somebody else's plan
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
next prev parent reply other threads:[~2007-11-28 15:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-28 4:37 Question regarding mutex locking Larry Finger
2007-11-28 8:10 ` Matthias Kaehlcke
2007-11-28 14:46 ` Larry Finger
2007-11-28 15:00 ` Matthias Kaehlcke [this message]
2007-11-28 15:22 ` Andreas Schwab
2007-11-28 15:41 ` Larry Finger
2007-11-28 22:45 ` Jarek Poplawski
2007-11-28 22:56 ` Jarek Poplawski
2007-11-28 23:07 ` Jarek Poplawski
2007-11-28 23:33 ` Stephen Hemminger
2007-11-29 6:40 ` Jarek Poplawski
2007-11-30 1:13 ` Bryan O'Sullivan
[not found] <fa.C9TdvYAhY8SablNc39IpD8WDnNM@ifi.uio.no>
2007-11-28 4:53 ` Robert Hancock
2007-11-28 5:19 ` Larry Finger
2007-11-29 2:34 ` David Schwartz
2007-11-29 7:56 ` Jarek Poplawski
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=20071128150055.GK20238@traven \
--to=matthias.kaehlcke@gmail.com \
--cc=larry.finger@lwfinger.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 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.