Wednesday, September 1, 2010

barrier ... cont

1.we have statements

stmt1;
stmt2;
------marker
'mystmt'
stmt3;

here the programmer is of the assumption that by the time control reaches marker
the 2 statements are finished completely and stmt3 would be a new sequence of commands
we can safely put since our assumptions are right here
But we are seeing the code from a code space angle
the code internally is generated by compiler , that is not bound by any strict criteria
for optimization it can reorganize codes in different ways
ie some of the side effects of stmt1 and 2 would be executed after stmt3
this can create serious problem when critical mystmts are executed with assumptions

memory barriers cont

1.linux kernel
http://www.mjmwired.net/kernel/Documentation/memory-barriers.txt
2.memory barrier good article
http://docs.google.com/viewer?a=v&q=cache:S9JEE_dIcGAJ:citeseerx.ist.psu.edu/viewdoc/download%3Fdoi%3D10.1.1.152.5245%26rep%3Drep1%26type%3Dpdf+memory+barriers&hl=en&pid=bl&srcid=ADGEESh5AL6JDRzYXbpein1NW-r5Uvq7ADoDeBi_kHvvcq64wzhwIhwAbBQCWfkUPz_XcxyD_isWsjCeeRjoqpDcYIpNIdYYMVai0Dc3W3Pj-38yUX9O7I1fkDdQFJ2G9Dwjiv9Wzzz2&sig=AHIEtbSZkOLsDotrYKqhAIgWi2DF9un-zg