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 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di Ravi Narayanaswamy (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);
}

Ritratto di Ravi Narayanaswamy (Intel)

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.

Accedere per lasciare un commento.