From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [patch 1/1] hwmon-pc87360 : avoid lock & unlock
Date: Mon, 06 Feb 2006 10:17:20 +0000 [thread overview]
Message-ID: <SoAVfSM1.1139221040.8836220.khali@localhost> (raw)
In-Reply-To: <43E6E432.8030408@gmail.com>
Hi Jim,
On 2006-02-06, Jim Cromie wrote:
> Modifies pc87360_update_device() to avoid locking & unlocking
> when data is not actually being resampled. Also re-indented
> the body of the function, removing the now extra tabs.
Imagine that two user-space processes read sysfs files and trigger the
update, at the same time. With the original locking model, both
processes will attempt to get the lock. One only (A) will succeed, while
the other (B) will have to wait. (A) will then test the time condition,
and update the data if needs be, then release the lock. At this point,
(B) will be granted the lock, and will get to test the time condition.
As (A) just updated the timestamp, (B) will skip the update as intended,
and release the lock immediately.
With your changes, (A) and (B) will test the time condition concurrently.
If an update is needed, they will fight for the lock. (A) will get it
and do the update, then release the lock. Then (B) will get it and do
the update again! Then release the lock. So you actually had two
consecutive updates, while the caching mecanism precisely tries to avoid
this.
So this doesn't work, sorry.
--
Jean Delvare
prev parent reply other threads:[~2006-02-06 10:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-06 5:52 [lm-sensors] [patch 1/1] hwmon-pc87360 : avoid lock & unlock when Jim Cromie
2006-02-06 10:17 ` Jean Delvare [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=SoAVfSM1.1139221040.8836220.khali@localhost \
--to=khali@linux-fr.org \
--cc=lm-sensors@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.