Some syntactical issue

Some syntactical issue

Hi,

Is it possible to end the transaction conditionally? I mean if a start the transaction by beginning the atomic block __tm_atomic, but I want to end the trannsaction based on some condition.

Consider a lock based code:
-------------------------------------
foo() {
LOCK(x)
..
..
if(...) {
UNLOCK(x);
return;
}
..
UNLOCK(x);
}
-------------------------------------

How could I achieve the same functionality using atomic blocks?

Thanks,
Neelam

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

have you tried something like

foo{

__tm_atomic {

if (...)
return;

}

return;

}

In this case the compiler gives me a warning: return from within atomic block.

Also what if I have more statements in the if block, something like:

foo() {
LOCK(x(;
...
if(..) {
stmt1;
stmt2;
UNLOCK(x);
return;
}
..
UNLOCK(x);
}

The warning is just to let you know that there was a return in the atomic block. You can have exit anywhere in your atomic block and it should work fine. The example you have shown should work fine.

Leave a Comment

Please sign in to add a comment. Not a member? Join today