▁processes , ▁the ▁entry ▁and ▁exit ▁from ▁critical ▁section ▁is ▁extremely ▁efficient ▁when ▁De k ker ' s ▁algorithm ▁is ▁used . ▁ ▁Many ▁modern ▁CPU s ▁execute ▁their ▁instructions ▁in ▁an ▁out - of - order ▁fashion ; ▁even ▁memory ▁access es ▁can ▁be ▁re ordered ▁( see ▁memory ▁ordering ). ▁This ▁algorithm ▁won ' t ▁work ▁on ▁S MP ▁machines ▁equ ipped ▁with ▁these ▁CPU s ▁without ▁the ▁use ▁of ▁memory ▁bar riers . ▁ ▁Additionally , ▁many ▁optim izing ▁comp ilers ▁can ▁perform ▁transformations ▁that ▁will ▁cause ▁this ▁algorithm ▁to ▁fail ▁regardless ▁of ▁the ▁platform . ▁ ▁In ▁many ▁languages , ▁it ▁is ▁legal ▁for ▁a ▁compiler ▁to ▁detect ▁that ▁the ▁flag ▁variables ▁wants _ to _ enter [ 0 ] ▁and ▁wants _ to _ enter [ 1 ] ▁are ▁never ▁accessed ▁in ▁the ▁loop . ▁ ▁It ▁can ▁then ▁remove ▁the ▁writes ▁to ▁those ▁variables ▁from ▁the ▁loop , ▁using ▁a ▁process ▁called ▁loop - in variant ▁code ▁motion . ▁ ▁It ▁would ▁also ▁be ▁possible ▁for ▁many ▁comp ilers ▁to ▁detect ▁that ▁the ▁turn ▁variable ▁is ▁never ▁modified ▁by ▁the ▁inner ▁loop , ▁and ▁perform ▁a ▁similar ▁transformation , ▁resulting ▁in ▁a ▁potential ▁infinite ▁loop . ▁ ▁If ▁either ▁of ▁these ▁transformations ▁is ▁performed , ▁the ▁algorithm ▁will ▁fail , ▁regardless ▁of ▁architecture . ▁ ▁To ▁alle vi ate ▁this ▁problem , ▁vol atile ▁variables ▁should ▁be ▁marked ▁as ▁mod ifiable ▁outside ▁the ▁scope ▁of ▁the ▁currently ▁executing ▁context . ▁For ▁example , ▁in ▁C # ▁or