From: Kedar Sovani <kedars@gmail.com>
To: rusty@rustcorp.com.au,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
kedars@gmail.com
Subject: Unreliable Guide to Locking - Addition?
Date: Mon, 8 Aug 2005 18:41:53 +0530 [thread overview]
Message-ID: <5edf7fc905080806117df1ab32@mail.gmail.com> (raw)
Hi Rusty,
I was going through the splendidly written document,
"Unreliable Guide to Locking". I thought of something that should be
mentioned in the section "Using Atomic Operations For The Reference
Count" (link : http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/x352.html#EXAMPLES-REFCNT-ATOMIC)
I guess, probably the section should also mention that
"
There is one race condition while using atomic_t, which is as follows :
* The refcount of the object is "1".
* Process A tries to perform atomic_dec_and_test(), gets "0" and hence
performs a kfree() on the object.
* Process B tries to perform atomic_inc() on the object.
* It may so happen that the atomic_inc() of Process B is called after
atomic_dec_and_test(), but before the kfree() call, which is a race
condition.
Usually, this race condition is avoided as:
when the last atomic_dec_and_test() (the last == the one which
returns 0) is being called on the object, the object is usually not
accessible to others (list_del()) and hence the simultaneous
atomic_inc() call never occurs.
"
Do you think this race condition should be included in the document?
Thanks,
Kedar.
next reply other threads:[~2005-08-08 13:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-08 13:11 Kedar Sovani [this message]
2005-08-09 2:35 ` Unreliable Guide to Locking - Addition? Rusty Russell
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=5edf7fc905080806117df1ab32@mail.gmail.com \
--to=kedars@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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.