From: Joe Korty <joe.korty@ccur.com>
To: Lars Unin <lars_unin@linuxmail.org>
Cc: hahn@physics.mcmaster.ca, linux-kernel@vger.kernel.org
Subject: Re: kernel spinlocks; when to use; when appropriate?
Date: Sat, 14 Jun 2003 20:50:20 -0400 [thread overview]
Message-ID: <20030615005020.GA16776@tsunami.ccur.com> (raw)
In-Reply-To: <20030614164144.8583.qmail@linuxmail.org>
> I wrote a while ago (thanks to you guys on LKML I almost
> understand now):
I missed the start of this thread, so forgive me if I state what was
stated before.
Use semaphores when the average hold time will be much longer than
two context switches, spinlocks for everything else. Semaphores when
contended force the process to go to sleep (one context switch), later,
the process will be switched back in when it gets the semaphore (another
context switch). This double context switch takes a fixed amount of
time and if you can get through your critical region much faster than
that fixed time, then it should be protected by a spinlock.
There are places where you have to use spinlocks irrespective of the
above: when in interrupt code (where sleeping is not allowed), and in
regions of code where some other spinlock is held (where sleeping is also
not allowed). The latter is especially insideous -- the more kernel
code protected by spinlocks, the more likely those existing spinlocks
will force new code to have to use spinlocks instead of semaphores.
Joe
next prev parent reply other threads:[~2003-06-15 0:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-14 16:41 kernel spinlocks; when to use; when appropriate? Lars Unin
2003-06-15 0:50 ` Joe Korty [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-06-09 16:01 Lars Unin
2003-06-09 17:21 ` Eli Carter
2003-06-09 15:43 Lars Unin
2003-06-09 15:50 ` Jonathan Corbet
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=20030615005020.GA16776@tsunami.ccur.com \
--to=joe.korty@ccur.com \
--cc=hahn@physics.mcmaster.ca \
--cc=lars_unin@linuxmail.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox