Some syntactical issue

Some syntactical issue

imagem de neegoyal

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
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Ravi Narayanaswamy (Intel)

have you tried something like


foo{


__tm_atomic {


if (...)
return;


}


return;


}

imagem de neegoyal

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);
}

imagem de 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.

Faça login para deixar um comentário.