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 {
workMID = MY_MID;
}
+ Task localTask;
int chk;
int result;
int i,j;
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 {
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;
int num_threads;
int status;
boolean chk = false;
- Segment s;
+ Object s;
atomic {
myID = mywork.MY_MID;
atomic {
- s = (Segment)mywork.currentWorkList[i];
+ s = mywork.currentWorkList[i];
if(status == -1 && null != s) {
mywork.currentWorkList[myID] = mywork.currentWorkList[i];