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 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

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.

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui