mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Oeser <ioe-lkml@rameria.de>
To: Frank Cusack <fcusack@fcusack.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: preemption when running in the kernel
Date: Sat, 8 Nov 2003 14:01:59 +0100	[thread overview]
Message-ID: <200311081402.07345.ioe-lkml@rameria.de> (raw)
In-Reply-To: <20031107040427.A32421@google.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Frank,

[CC'ed lkml to avoid duplicate answers]

On Friday 07 November 2003 13:04, Frank Cusack wrote:
> (2.4 kernel)
>
> When a process is running in the kernel, can it be pre-empted at
> any time?  (Unless you explicity disable preemption.)  I think not,
> because wouldn't it be unsafe to grab a spinlock?  Or does grabbing a
> spinlock disable preemption.  I mean spin_lock(), not spin_lock_irqsave().

While having preemption disabled or while actually holding a spinlock,
preemption is disabled.

Disabling preemption is modifying a count, which must reach 0 again to
have preemption enabled and trigger an reschedule, if needed.

Think of it roughly as a "counter of reasons to not preempt". If there
are no reasons anymore, then we preempt.

> Secondly, can multiple processes be in the kernel at the same time?  I
> think so, that's the reason for the fine grained locks instead of the BKL.
> Or do fine grained locks only serve to allow preemption.

Multiple threads can be in the kernel at the same time and even on
different CPUs. But one thread can be only on one CPU at any time.

Threads are parts of processes, so the same applies for processes, too.


Regards

Ingo Oeser

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/rOlHU56oYWuOrkARAqz9AJ9bi71xchjKUJs8kysa6ePKpk13nwCeL1NB
2ti5dqrV6sQjDNbc/RqOItM=
=rb5C
-----END PGP SIGNATURE-----


  reply	other threads:[~2003-11-08 13:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-07 12:04 Frank Cusack
2003-11-08 13:01 ` Ingo Oeser [this message]
2003-11-09  0:23   ` Robert Love
2003-11-09 10:04     ` Frank Cusack
2003-11-09 17:56       ` Robert Love

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=200311081402.07345.ioe-lkml@rameria.de \
    --to=ioe-lkml@rameria.de \
    --cc=fcusack@fcusack.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

all inboxes | Powered by JetHome®