[Tinyos-help] about atomic block
m.khezri
a4farance at gmail.com
Thu Jul 17 06:19:04 PDT 2008
Hello,
I read the tinyos programming guide, but didn't understand exactly
this part of manual(page 41) :
"The atomic block promises that these variables can be read and
written atomically. Note that this does
not promise that the atomic block won't be preempted. Even with atomic
blocks, two code segments that do
not touch any of the same variables can preempt one another. For example:
async command bool a() {
atomic {
a++;
b = a + 1;
}
}
async command bool c() {
atomic {
c++;
d = c + 1;
}
}
In this example, c can (theoretically) preempt a without violating
atomicity. But a can't preempt itself,
nor can c preempt itself."
my questions :
1-In the above example how c can preempt a?
2-When atomic code is being executed , interrupts are disabled , so
why this does
not promise that the atomic block won't be preempted?
thanks
More information about the Tinyos-help
mailing list