Same clock across multiple threads in multiple places

0 views
Skip to first unread message

John Gallagher

unread,
Dec 10, 2010, 2:37:28 PM12/10/10
to coms49...@googlegroups.com
Hi all, I would like to have the same clock across multiple places
across multiple threads.

Here is the only one I have been able to come up with that doesn't
give me a compiler error or a Clock use exception. However, it
doesn't give the desired result (which you can probably see from the
code)

clocked finish for([p] in 0..Place.MAX_PLACES -1 )
{
clocked async at (Place.place(p))
{

finish for([threadId] in 0..nThreads-1)
{
async
{

Console.OUT.println(here.id()+1);
next;

Console.OUT.println((here.id()+1) * 10);
next;
}
}


}
}

For 4 places, 2 threads per place, I would like to see:

some permutation of:
1
1
2
2
3
3
4
4
then some permutation of:
10
10
20
20
30
30
40
40


Any verified code that can do this? I've tried named clocks (clock
use exception or deadlock) nested implicit clocks (compiler error).
Any help would be greatly appreciated.

Thanks very much,
John

Vijay Saraswat

unread,
Dec 10, 2010, 6:48:49 PM12/10/10
to coms49...@googlegroups.com
Try this. You cant say "finish for ([threadId] in 0..2-1)..." since the finish will cause a deadlock. (The activity executing the finish is the clocked async at (Place.place(p)), so its registered on the clock. When executing the finish it cannot do a next, hence the clock cannot advance, leading to deadlock.)

You need to have the innermost async be clocked, so the async is actually clocked on some clock.


class C {
public static def main(Array[String]) {


clocked finish for([p] in 0..Place.MAX_PLACES -1 )
{
clocked async at (Place.place(p))
{

for([threadId] in 0..2-1)
{
clocked async

John Gallagher

unread,
Dec 10, 2010, 6:50:55 PM12/10/10
to coms49...@googlegroups.com
Thanks!

john

Reply all
Reply to author
Forward
0 new messages