|
Hi,
I have been trying to figure out atomicity notion in VCC. For the following small example,
_(dynamic_owns) struct T { int x;};
struct T *t;
void foo()
_(requires \wrapped(t) )
_(writes \span(t))
_(requires t->x < INT_MAX)
_(ensures t->x == \old(t->x) + 1)
{ _(unwrapping t) // line 0
t->x += 1;
//line 1
// line 2
_(wrap t) // line 3
_(assert t->x == \old(t->x)+1 )
}
Verification of foo method succeeds
It would be great if you can help me to make the following points clear for me.
1. 'unwrapping' sets the ownership of object and its subfields to current thread. Is it
something that includes implicit synchronization on object and its subfields, like implicit
lock? If it is the case, the block between _(unwrapping t) ... _(wrap t) can lead us to
reason about the operations on t and its subfields performed atomically, right?
2. However, I think point 1, atomicity issue, is not provided by these wrap and unwrap
constructs. Because, _(assert t->x == \old(t->x)+1) or the reverse of this assertion
always passes and I cant really understand why this happens.
Conclusion and questions:
Does it mean that we need an expilicit synchronization objects like explicit lock
modelling associated with object and use it before unwrapping and wrapping objects?
_(lock t->lock)
_(unwrapping t)
_(wrap t)
_(unlock t->lock)
If I can be sure about these notions , I can be going on different models , relaxations about these constructs.
THANKS IN ADVANCE!
Ismail
|