Deuce apis (for a beginner to deuce)

64 views
Skip to first unread message

Richard

unread,
Feb 12, 2010, 5:34:48 PM2/12/10
to Deuce-STM developers
Hi Guys,

I am doing a final year project at university. I am building a hybrid
STM which uses existing lock inferencing work and your STM.

I was wondering if you could point me any documentation of the main
parts of the Deuce Api. So far all I have knowledge of is @Atomic. Can
I do things like roll back or abort transactions in my code? I need to
do things like keep track of the number roll backs etc. (one way I
have found to do this is by adding a catch block around the code in
question and catch the TransactionExceptions thrown).

Thanks,

Richard

Guy Korland

unread,
Feb 12, 2010, 5:52:57 PM2/12/10
to deuce-stm-developers
> Can I do things like roll back or abort transactions in my code?
You can throw TransactionException to force a transaction retry.

>I need to do things like keep track of the number roll backs etc. 
You can easily do it by using the Context API.

Regards,
Guy Korland



--
You received this message because you are subscribed to the Google Groups "Deuce-STM developers" group.
To post to this group, send email to deuce-stm-...@googlegroups.com.
To unsubscribe from this group, send email to deuce-stm-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/deuce-stm-developers?hl=en.


Richard Gill

unread,
Feb 19, 2010, 9:19:21 AM2/19/10
to deuce-stm-developers
Thanks for this advice. 

I am trying to get a transaction abort in the following example. However I can't get it to work as an exception is occurring I would not have expected.

The simple code I am using is :

@Atomic
public int increment() throws InterruptedException {

int countTemp = count;
Thread.sleep(100);
count = countTemp + 1;
if (count > 90) {
System.out.println("Try Again" + count);
throw new TransactionException();
/*Context context = ContextDelegator.getInstance();
context.rollback();
System.out.println("Rollback!");*/
}

return count;
}

I then start 10 threads incrementing the counter 10 times each. (So the counter reaches 100!). After 90 I want to abort the transactions. You can see two attempts in the code (one commented out). Both throw similar exceptions as follows :

Exception in thread "Thread-5" java.lang.NoSuchMethodError: org.deuce.transaction.TransactionException.<init>(Lorg/deuce/transaction/Context;)V
at Counter.incrementbytwo(Counter.java:16)
at Counter.incrementbytwo(Counter.java)
at ExampleMain$1.run(ExampleMain.java:20)
at java.lang.Thread.run(Unknown Source)

I don't understand why this exception is being thrown.

Is there any sample code I can look at? Am I doing it right? And on a side note, is this how you get an instance of the context?

Thanks for your help,

Richard

Guy Korland

unread,
Feb 21, 2010, 5:48:22 PM2/21/10
to deuce-stm-developers
That bug was fixed in the upcoming Deuce 1.3

Workaround: -Dorg.deuce.exclude="java.*,sun.*,org.eclipse.*,org.deuce.*"

Regards,
Guy Korland

Richard Gill

unread,
Feb 22, 2010, 10:42:33 AM2/22/10
to deuce-stm-developers
Ok thanks, that has helped a lot. However I have now spent a reasonable amount of time trying to figure out how to rollback and abort a transaction. (So it doesn't just reexecute.). 

Is it possible to do this?

Many Thanks,

Richard 

Guy Korland

unread,
Feb 23, 2010, 3:03:50 AM2/23/10
to deuce-stm-developers
Currently Deuce doesn't support Abort but only Retry as you notice.
I'm planning to add it in the next version (1.3) which is expected in less than a week.
You can hack the code if you want check out org.deuce.transform.asm.method.AtomicMethod.
You can add a code that can abort on different exception. 

Regards,
Guy Korland

Mihai Letia

unread,
Feb 23, 2010, 5:27:50 AM2/23/10
to deuce-stm-...@googlegroups.com
I think Retry is what I wanted to say.
The difference, I'm guessing is that Abort means that it is not restarted.
It would be useful to know how many times a transaction was attempted
before it's committed.

Best,
Mihai

Guy Korland wrote:
> Currently Deuce doesn't support Abort but only Retry as you notice.
> I'm planning to add it in the next version (1.3) which is expected in
> less than a week.
> You can hack the code if you want check out
> org.deuce.transform.asm.method.AtomicMethod.
> You can add a code that can abort on different exception.
>
> Regards,
> Guy Korland
>
>
> On Mon, Feb 22, 2010 at 5:42 PM, Richard Gill <richar...@gmail.com
> <mailto:richar...@gmail.com>> wrote:
>
> Ok thanks, that has helped a lot. However I have now spent a
> reasonable amount of time trying to figure out how to rollback and
> abort a transaction. (So it doesn't just reexecute.).
>
> Is it possible to do this?
>
> Many Thanks,
>
> Richard
>
> On 21 February 2010 22:48, Guy Korland <gkor...@gmail.com

> <mailto:gkor...@gmail.com>> wrote:
>
> > Can I do things like roll back or abort transactions
> in my code?
> You can throw TransactionException to force a
> transaction retry.
>
> >I need to do things like keep track of the number
> roll backs etc.
> You can easily do it by using the Context API.
>
> Regards,
> Guy Korland
>
>
> On Sat, Feb 13, 2010 at 12:34 AM, Richard
> <richar...@gmail.com

> <mailto:deuce-stm-...@googlegroups.com>.


> To unsubscribe from this group, send email to
> deuce-stm-develo...@googlegroups.com

> <mailto:deuce-stm-developers%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/deuce-stm-developers?hl=en.
>
>
> --
> You received this message because you are subscribed
> to the Google Groups "Deuce-STM developers" group.
> To post to this group, send email to
> deuce-stm-...@googlegroups.com

> <mailto:deuce-stm-...@googlegroups.com>.


> To unsubscribe from this group, send email to
> deuce-stm-develo...@googlegroups.com

> <mailto:deuce-stm-developers%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/deuce-stm-developers?hl=en.
>
>
> --
> You received this message because you are subscribed to
> the Google Groups "Deuce-STM developers" group.
> To post to this group, send email to
> deuce-stm-...@googlegroups.com

> <mailto:deuce-stm-...@googlegroups.com>.


> To unsubscribe from this group, send email to
> deuce-stm-develo...@googlegroups.com

> <mailto:deuce-stm-developers%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/deuce-stm-developers?hl=en.
>
>
> --
> You received this message because you are subscribed to the
> Google Groups "Deuce-STM developers" group.
> To post to this group, send email to
> deuce-stm-...@googlegroups.com

> <mailto:deuce-stm-...@googlegroups.com>.


> To unsubscribe from this group, send email to
> deuce-stm-develo...@googlegroups.com

> <mailto:deuce-stm-developers%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/deuce-stm-developers?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Deuce-STM developers" group.
> To post to this group, send email to
> deuce-stm-...@googlegroups.com

> <mailto:deuce-stm-...@googlegroups.com>.


> To unsubscribe from this group, send email to
> deuce-stm-develo...@googlegroups.com

> <mailto:deuce-stm-developers%2Bunsu...@googlegroups.com>.

Guy Korland

unread,
Feb 23, 2010, 6:12:05 AM2/23/10
to deuce-stm-developers
Ok, so this is pretty easy to implement as part of the Context.
Just add a counter to the init(), rollback() and commit().

Regards,
Guy Korland

Guy Korland

unread,
Feb 23, 2010, 6:12:20 AM2/23/10
to deuce-stm-developers
Ok, so this is pretty easy to implement as part of the Context.
Just add a counter to the init(), rollback() and commit

Regards,
Guy Korland


On Tue, Feb 23, 2010 at 12:27 PM, Mihai Letia <mihai...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages