Ok, so if I understand right, it is as the following program shows, where "x" is constantly changing, but "y" is like the mutex.
- Code: Select all
In this example, both variables are global, and can be read constantly.
Only "y" is like a mutex, where you do not see the effect of the "++" until
"y" is "released".
int x,y; //both x and y are global
x=y; //aquiring the mutex
repeat(100) //repeat 100 times before pausing
x++; //x is changeing constantly
Wait(10); //slow down so we can see it
y=x; //releasing the mutex
x=0; //just to prove that it needs to aquire the mutex
Wait(500); //pause to see the effect
NumOut(0,LCD_LINE1,x); //display current x
NumOut(0,LCD_LINE2,y); //display current y
Wait(50); //so it doesn't hog the processor
start working; //start doing stuff
start display; //start displaying
So it is sort of like this, and another task might to math to "z", and then write "y" to that value. I think I understand now the difference, but I am not sure exactly how to explain it. Basically, this example still lacks the ability to stop another task from using "y", where a mutex would stop it temporarily.
Is this the general idea of what you mean?
Edited code slightly (and again).