run execute method outside of transaction
authorjihoonl <jihoonl>
Thu, 24 Sep 2009 18:33:53 +0000 (18:33 +0000)
committerjihoonl <jihoonl>
Thu, 24 Sep 2009 18:33:53 +0000 (18:33 +0000)
Robust/src/ClassLibrary/JavaDSM/Task.java
Robust/src/ClassLibrary/JavaDSM/Work.java

index c4119819b928b30284c212aa7883ce3743298d24..355cc4cca5470a3c3f499b424ba4323e5497c0f2 100644 (file)
@@ -1,13 +1,25 @@
 public class Task {
   Queue todoList;
        Queue doneList;
+  Object myWork;
 
        Task() {}
 
        public void init();     
-       public void execute(Object work);
+       public native void execution();
+  public void execute() {
+    System.out.println("Sad");
+  }
+
        public void done(Object work);
 
+  public void setWork(Object work)
+  {
+    atomic {
+      this.myWork = work;
+    }
+  }
+
        public Object grabTask() {
                Object o;
                atomic {
index 56e18d1be4a77c827820be6e840577ee6cb86e2e..9b9c164a10436cbab14a6afe984b55ca66f81a42 100644 (file)
@@ -17,6 +17,7 @@ public class Work extends Thread {
       workMID = MY_MID;
     }
 
+    Task localTask;
     int chk; 
     int result;
     int i,j;
@@ -28,9 +29,7 @@ public class Work extends Thread {
                                        isEmpty = tasks.isTodoListEmpty();              // flag > !keep assigning 
                        
           if (!isEmpty) {
-                             atomic {
-                               currentWorkList[workMID] = tasks.grabTask();    /* grab the work from work pool */
-                               }
+                       currentWorkList[workMID] = tasks.grabTask();    /* grab the work from work pool */
             chk = 1;
           }
                        else {
@@ -40,19 +39,19 @@ public class Work extends Thread {
 
       if(chk == 1) {    // still have work
         atomic {
-          /* compute */
-          tasks.execute(currentWorkList[workMID]);
-          /* push into done list */
-          tasks.done(currentWorkList[workMID]);
-                                       currentWorkList[workMID] = null;
+          tasks.setWork(currentWorkList[workMID]);
+          localTask = tasks;
         }
 
+        /* compute */
+        localTask.execution();
+
         atomic {
+          /* push into done list */
+          tasks.done(currentWorkList[workMID]);
+                                       currentWorkList[workMID] = null;
           cc = ((Drinker)tasks).ownTotal;
         }
-
-//        System.out.println("CC = " + cc);
-//        sleep(1000000);
       }
       else if(chk  == -1) {    // finished all work
         break;
@@ -78,7 +77,7 @@ public class Work extends Thread {
                int num_threads; 
     int status;
     boolean chk = false;
-    Segment s;
+    Object s;
 
                atomic {
            myID = mywork.MY_MID;
@@ -93,7 +92,7 @@ public class Work extends Thread {
 
       atomic {
 
-        s = (Segment)mywork.currentWorkList[i];
+        s = mywork.currentWorkList[i];
 
         if(status == -1 && null != s) {
           mywork.currentWorkList[myID] = mywork.currentWorkList[i];