Add initial functions for thread join support
authoradash <adash>
Thu, 3 Jan 2008 17:50:49 +0000 (17:50 +0000)
committeradash <adash>
Thu, 3 Jan 2008 17:50:49 +0000 (17:50 +0000)
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/ClassLibrary/Thread.java
Robust/src/ClassLibrary/ThreadDSM.java
Robust/src/Runtime/thread.c
Robust/src/Tests/Atomic5.java

index 1a7f5ce1e41af729d655b2ea00ae9c73137361d6..20a968b0d565d1af9ecac80d3dae7d52852c3a80 100644 (file)
@@ -333,6 +333,7 @@ public class LocalityAnalysis {
        MethodDescriptor nodemd=fc.getMethod();
        Set methodset=null;
        Set runmethodset=null;
+
        if (nodemd.isStatic()||nodemd.getReturnType()==null) {
            methodset=new HashSet();
            methodset.add(nodemd);
@@ -357,11 +358,18 @@ public class LocalityAnalysis {
                    methodset.addAll(runmethodset);
                } else throw new Error("Can't find run method");
            }
+           /* Add New Check for Thread Join */
+           if (nodemd.getClassDesc().getSymbol().equals(TypeUtil.ThreadClass)&&
+               nodemd.getSymbol().equals("join")) {
+               assert(nodemd.getModifiers().isNative());
+           }
        }
+
        Integer currreturnval=EITHER; //Start off with the either value
        for(Iterator methodit=methodset.iterator();methodit.hasNext();) {
            MethodDescriptor md=(MethodDescriptor) methodit.next();
            boolean isnative=md.getModifiers().isNative();
+           boolean isjoin = md.getSymbol().equals("join");
 
            LocalityBinding lb=new LocalityBinding(md, isatomic);
            if (isnative&&isatomic) {
@@ -388,9 +396,13 @@ public class LocalityAnalysis {
                    throw new Error("Starting thread on local object not allowed in context:\n"+currlb.getExplanation());
                if(thistype.equals(CONFLICT))
                    throw new Error("Using type that can be either local or global in context:\n"+currlb.getExplanation());
-               if(runmethodset==null&&thistype.equals(GLOBAL)&&!isatomic)
+               //if(runmethodset==null&&thistype.equals(GLOBAL)&&!isatomic)
+               /* TODO Remove this ..This is a hack for thread join() call */
+               if(runmethodset==null&&thistype.equals(GLOBAL)&&!isatomic && !isjoin) 
                    throw new Error("Using global object outside of transaction in context:\n"+currlb.getExplanation());
-               if (runmethodset==null&&isnative&&thistype.equals(GLOBAL))
+               //if (runmethodset==null&&isnative&&thistype.equals(GLOBAL))
+               /* TODO Remove this ..This is a hack for thread join() call */
+               if (runmethodset==null&&isnative&&thistype.equals(GLOBAL) && !isjoin)
                    throw new Error("Potential call to native method "+md+" on global objects:\n"+currlb.getExplanation());
                lb.setGlobalThis(thistype);
            } 
index 3008a067012d806701ed2c5e0103914e145d539e..c44043bdcc499dc29177e7e910e84c973115d0a3 100644 (file)
@@ -1,4 +1,5 @@
 public class Thread {
+
     public void start() {
        nativeCreate();
     }
@@ -12,4 +13,5 @@ public class Thread {
     public void run() {}
 
     private native void nativeCreate();
+
 }
index f6ba8cf362e5f53fe07f26419055ff27eb7fd914..322a022b3c3a644155b7e5d95782d3eb66847535 100644 (file)
@@ -1,6 +1,14 @@
 public class Thread {
     /* Don't allow overriding this method.  If you do, it will break dispatch
      * because we don't have the type information necessary. */
+    private boolean threadDone;
+
+    public Thread() {
+        threadDone = false;
+    }
+
+    //public native static void join();
+    public native void join();
 
     public final native void start(int mid);
 
index 235b4ed930feb21fbd20ecac8d33bf9a7a369068..d306ecebf03a88c3aa66db733f550e6bd847dac4 100644 (file)
@@ -98,6 +98,13 @@ void CALL11(___Thread______sleep____J, long long ___millis___, long long ___mill
 #endif
 }
 
+/* Add thread join capability */
+#ifdef DSTM
+void CALL01(___Thread______join____, struct ___Thread___ * ___this___) {
+  printf("DEBUG -> Inside native join\n");
+}
+#endif
+
 #ifdef THREADS
 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
   pthread_t thread;
index b0160029bfc3c756d102011264d7a6e4a1f98b50..9d8f3377e961ab09e0ec1b04ab383e78fcc59537 100644 (file)
@@ -8,7 +8,7 @@ public class Atomic5 extends Thread {
                
                Integer age;
                String name;
-               Atomic at5[];
+               Atomic5 at5[];
                atomic {
                        at5[] =  global new Atomic5[4];
                }