why no memory barriers on example code ?
Posted: Thu Jan 05, 2012 5:06 pm
Hi guys... Just a quick question.
Ive noticed the lack of any memory barriers in some of the wiki code snippets.
Have I completely misunderstood out-of-order execution ?
for example, take the following code snipped from the IO-APIC wiki page.
Don't we need an sfence between the two writes, to make sure the value doesn't get written before the register is selected ?
Surely the out of order execution engine isn't clever enough to see the virtual address writes are mapped to the IOAPIC ?
Thanks.
Ive noticed the lack of any memory barriers in some of the wiki code snippets.
Have I completely misunderstood out-of-order execution ?
for example, take the following code snipped from the IO-APIC wiki page.
Code: Select all
void write_ioapic_register(const ptr_t apic_base, const uint8_t offset, const uint32_t val)
{
/* tell IOREGSEL where we want to write to */
*(uint32_t*)(apic_base) = offset;
/* write the value to IOWIN */
*(uint32_t*)(apic_base + 0x10) = val;
}
Surely the out of order execution engine isn't clever enough to see the virtual address writes are mapped to the IOAPIC ?
Thanks.