tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel_lock prememption

Rohan Akela <> writes:

> I would like to know if a thread holding kernel_lock which is a spinlock
> can be preempted or not ?
> The implementation of kernel_lock in kern_lock.c seems to suggests that it
> can be preempted because the it uses splvm which implies IPL_VM. So a
> thread holding kernel_lock can be interrupted by clock interrupt and then
> scheduler can put the thread to sleep. This behavior is contrary to the
> classic definition of spinlock.
> Is my understanding correct ?

This is hard to understand.  My memory is slightly fuzzy, but I believe
that KERNEL_LOCK is special in that it's automatically released and
reacquired across scheduling.  In addition to acquiring the big lock for
protection from other processors, one needs to splfoo() to protect
against same-cpu interrupts that might try to acquire the big lock.

I suggest reading 'man 9 lock', and then the source code.  Arguably
there should be a KERNEL_LOCK(9) man page; there isn't in -6.

Attachment: pgpJSvir_redN.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index