public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: linux-kernel@vger.kernel.org
Cc: Sorin Manolache <sorinm@gmail.com>
Subject: Re: newbie questions about while (1) in kernel mode and spinlocks
Date: Thu, 21 Dec 2006 08:31:54 -0600	[thread overview]
Message-ID: <458A9ADA.8040709@shaw.ca> (raw)
In-Reply-To: <fa.D8ff1OmLNpVeVOoaJAP7ENpm+Wk@ifi.uio.no>

Sorin Manolache wrote:
> 
> The Linux Device Drivers book says that a spin_lock should not be
> shared between a process and an interrupt handler. The explanation is
> that the process may hold the lock, an interrupt occurs, the interrupt
> handler spins on the lock held by the process and the system freezes.
> Why should it freeze? Isn't it possible for the interrupt handler to
> re-enable interrupts as its first thing, then to spin at the lock, the
> timer interrupt to preempt the interrupt handler and to relinquish
> control to the process which in turn will finish its critical section
> and release the lock, making way for the interrupt handler to
> continue.

When the timer interrupt finishes, it's not going to return control to 
the process, it's going to return control to what it interrupted which 
is the interrupt handler in your code which will just continue spinning. 
Interrupt handlers are not preemptible by anything other than other 
interrupt handlers (and then only in some cases) so it will sit spinning 
on that lock forever.

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/


       reply	other threads:[~2006-12-21 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.D8ff1OmLNpVeVOoaJAP7ENpm+Wk@ifi.uio.no>
2006-12-21 14:31 ` Robert Hancock [this message]
2006-12-21 18:14 newbie questions about while (1) in kernel mode and spinlocks SR, Krishna
  -- strict thread matches above, loose matches on Subject: below --
2006-12-21  9:41 Sorin Manolache
2006-12-21 10:05 ` Paolo Ornati
2006-12-21 10:20 ` Paolo Ornati
2006-12-21 10:40 ` Paolo Ornati
2006-12-21 23:54 ` Steven Rostedt

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=458A9ADA.8040709@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sorinm@gmail.com \
    /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