From: "Richard B. Johnson" <root@chaos.analogic.com>
To: RANDAZZO@ddc-web.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: spinlocks dont work
Date: Fri, 13 Feb 2004 11:48:57 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.53.0402131137180.488@chaos> (raw)
In-Reply-To: <89760D3F308BD41183B000508BAFAC4104B16F6F@DDCNYNTD>
On Fri, 13 Feb 2004 RANDAZZO@ddc-web.com wrote:
> On my uniprocessor system, I have two LKM's
>
> driver1 takes hold of the spinlock....but does not release it...
> driver2 attempts to take hold, and is allowed!!!!
> how come spin locks don't work?????
> how can I restrict access (to hardware) to only one driver at a time???
> should I use semaphores, etc...
>
Spin-locks do work. However, you need to use the same lock-object
for each execution path. A common error is to do:
static spinlock_t device_lock;
... in one file, and...
static spinlock_t device_lock;
... in another...
There is also a possibility that the kernel you are using does not
impliment spin-locks if it's not compiled for SMP. To make sure,
compile your uniprocessor machine for SMP.
Basically, you use semaphores when the particular execution path
can sleep, and spin-locks when they can't. You can never sleep
in an ISR, so you need to use spin-lock protection where something
could change as a result of an interrupt.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
next prev parent reply other threads:[~2004-02-13 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-13 16:27 spinlocks dont work RANDAZZO
2004-02-13 16:48 ` Richard B. Johnson [this message]
2004-02-13 16:59 ` Joe Thornber
2004-02-13 23:11 ` Rik van Riel
2004-02-14 0:21 ` Jamie Lokier
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=Pine.LNX.4.53.0402131137180.488@chaos \
--to=root@chaos.analogic.com \
--cc=RANDAZZO@ddc-web.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox