flâneur — a map of the web's best reading

Optimization barriers | Pintos Documentation

cs162.org · 725 words · saved by 1 readers

An optimization barrier is a special statement that prevents the compiler from making assumptions about the state of memory across the barrier. The compiler will not reorder reads or writes of variables across the barrier or assume that a variable’s value is unmodified across the barrier, except for local variables whose address is never taken. In Pintos, threads/synch.h defines the barrier() macro as an optimization barrier. One reason to use an optimization barrier is when data can change asynchronously, without the compiler’s knowledge, e.g. by another thread or an interrupt handler. The too_many_loops function in devices/timer.c is an example. This function starts out by busy-waiting in a loop until a timer tick occurs: Without an optimization barrier in the loop, the compiler could conclude that the loop would never terminate, because start and ticks start out equal and the loop itself never changes them. It could then “optimize” the function into an infinite loop, which would def

Optimization barriers | Pintos Documentation Skip to main content Menu Expand (external link) Document Search Copy Copied Pintos Documentation Optimization barriers An optimization barrier is a special statement that prevents the compiler from making assumptions about the state of memory across the barrier. The compiler will not reorder reads or writes of variables across the barrier or assume that a variable’s value is unmodified across the barrier, except for local variables whose address is never taken. In Pintos, threads/synch.h defines the barrier() macro as an optimization barrier. One r

Explore this link on the map →

related reading