lkml.org 
[lkml]   [2002]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: in_atomic() & spin_lock / spin_unlock in different functions
From
Date
On Sun, 2002-10-13 at 14:38, Pavel Machek wrote:

> I'm doing spin_lock_irqsave() then in another function
> spin_unlock_irqrestore. Is that okay? If no, can it cause "scheduling
> in atomic"?

It is not OK if the function is run by a different process. Then one
process will have a preempt_count one larger than it should and one
would have a preempt_count one smaller.

The task with the one smaller preempt_count will probably cause a crash
when it preemptively reschedules erroneously.

In other words, you have:

Process A Process B
preempt_count++
preempt_count--

When both of those routines need to be done by the same process.

Also, you cannot use spin_lock_irqsave() in different functions at all
on sparc as it contains stack information.

Robert Love

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

\
 
 \ /
  Last update: 2005-03-22 13:30    [from the cache]
©2003-2011 Jasper Spaans. Advertise on this site