Re: Question on spinlocks and reentrancy

Ingo Molnar (mingo@chiara.csoma.elte.hu)
Sat, 15 May 1999 21:37:02 +0200 (CEST)


On Fri, 14 May 1999, B. James Phillippe wrote:

> For example, say I am about to muddle with some members of current. If I
> am in init_module() do I need a spinlock (like lock_kernel())? How about
> in a system call that has no chance of sleeping? From within tq_scheduler?
> What about within a kernel thread? Say I do a "struct task_struct *task =
> current" and then only access members through task; do I still need a
> spinlock at all?

'current' is guaranteed to not go away under you. (that is true on both UP
and SMP). There are certain structures within 'current' that have a
spinlock, the signal structures for example. The rule typically is that if
a structure is completely private to 'current' then you need no spinlock.
Shared fields (eg. 'priority' can be set from another process) have either
the lock_kernel() protection (old, not yet SMP-parallelized code), or some
own spinlock/counter like the signal struct. Does this answer your
question?

-- mingo

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/