IRQs and memory consistency

Christopher Harvey chris at basementcode.com
Wed Apr 11 07:53:27 EDT 2012


On 10.04.2012 22:18, Mulyadi Santosa wrote:
> Hi....
>
> On Wed, Apr 11, 2012 at 03:22, Christopher Harvey
> <chris at basementcode.com> wrote:
>> The IRQ and the setting of the devid value happen fairly close to
>> each other in time. (like less than a second, or closer)
>
> Hmmm, and how about the order? which one do you guess go first?
> setting value? or the IRQ handler?
>
> I had a sense that your code flow might (in reality) goes like this
>
> allocating struct RAM --> interrupted --> printing struct content -->
> back to initialize struct
>
> If that's true, then no wonder 0 (zero) is printed.
>
> I suggest to grab a spin lock if you really need atomicity during
> allocation and setting initial value, which in IRQ handler, you grab
> the lock before printing. Oh and since memory allocation could go
> slow, you might need to do allocation with GFP_ATOMIC.

well, actually my does does this:

set variable->init hardware->interrupt

the interrupt can't happen until 'init hardware'




More information about the Kernelnewbies mailing list