adding a test case
[IRC.git] / Robust / src / Benchmarks / Prefetch / Chase / Chase.java
1 public class Foo {
2     Foo next;
3     public Foo() {
4       next=null;
5     }
6 }
7
8 public class Chase extends Thread {
9     Foo base;
10     public Chase(Foo b) {
11         base=b;
12     }
13     
14     public static void main(String [] argv) {
15         Chase c;
16         int numTraverse = 1000000;
17         if (argv.length>0)
18             numTraverse=Integer.parseInt(argv[0]);
19
20         atomic {
21             Foo fold=global new Foo();
22             
23             for(int i=0;i<numTraverse;i++) {
24                 Foo f=global new Foo();
25                 f.next=fold;
26                 fold=f;
27             }
28             
29             c=global new Chase(fold);
30         }
31         System.out.println("Starting");
32         c.start((128<<24)|(195<<16)|(136<<8)|162);
33         c.join();
34         System.out.println("Finished");
35     }
36     
37     public void run() {
38       atomic {
39         Foo b=base;
40         int i = 0;
41         while(b!=null) {
42           b=b.next;
43           i++;
44         }
45       }
46     }
47 }