> > I did not talk about memory barriers. In fact, barrier() is NOT a memory > > barrier. It's a compiler optimization barrier! > > > > // Read 10 samples from 2 A/D converters. > > int* ina; > int a[10]; > int* inb; > int b[10]; > > for (int i=0; i<10; i++) > { > a[i] = *ina; > barrier(); > b[i] = *inb; > } > > The barrier prevents the compiler of translating this to: > > for (int i=0; i<10; i++) > { > b[i] = *inb; > a[i] = *ina; > } > > or even to: > > for (int i=0; i<10; i++) > a[i] = *ina; > for (int i=0; i<10; i++) > b[i] = *inb; > > but does not prevent it to do this: yes it does. It's a full optimization barrier; the compiler assumes all register and memory content has changed from before the barrier(), and it will start "fresh". - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- References:
- Re: [patch] uninline init_waitqueue_*() functions
- From: Ingo Molnar <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Andrew Morton <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Ingo Molnar <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Andrew Morton <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Linus Torvalds <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Ingo Molnar <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Linus Torvalds <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Ingo Molnar <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Linus Torvalds <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- From: Linus Torvalds <[email protected]>
- [patch] spinlocks: remove 'volatile'
- From: Ingo Molnar <[email protected]>
- Re: [patch] spinlocks: remove 'volatile'
- From: "linux-os \(Dick Johnson\)" <[email protected]>
- Re: [patch] spinlocks: remove 'volatile'
- From: Arjan van de Ven <[email protected]>
- Re: [patch] spinlocks: remove 'volatile'
- From: "linux-os \(Dick Johnson\)" <[email protected]>
- Re: [patch] spinlocks: remove 'volatile'
- From: Arjan van de Ven <[email protected]>
- Re: [patch] spinlocks: remove 'volatile'
- From: "J.A. Magallón" <[email protected]>
- Re: [patch] uninline init_waitqueue_*() functions
- Prev by Date: Re: [PATCH 1/6] FDPIC: Fix FDPIC compile errors [try #3]
- Next by Date: Re: PATCH: Create new LED trigger for CPU activity (ledtrig-cpu) (UPDATED)
- Previous by thread: Re: [patch] spinlocks: remove 'volatile'
- Next by thread: Re: [patch] spinlocks: remove 'volatile'
- Index(es):