From c68d77348665b2244153099da5d49585fcbaec5e Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Mon, 18 Nov 2019 14:37:59 +0100 Subject: [PATCH] =?UTF-8?q?=09modified:=20=20=20../../../../main/java/de/d?= =?UTF-8?q?hbwstuttgart/typeinference/unify/TypeUnify2Task.java=20=09modif?= =?UTF-8?q?ied:=20=20=20../../../../main/java/de/dhbwstuttgart/typeinferen?= =?UTF-8?q?ce/unify/TypeUnifyTask.java=20Threadsteuerung=20veranendert,=20?= =?UTF-8?q?so=20dass=20m=C3=B6glichst=20veile=20Threads=20gleichzeitig=20l?= =?UTF-8?q?aufen.=20M=C3=BCsste=20noch=20verbessert=20werden=20k=C3=B6nnen?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../typeinference/unify/TypeUnify2Task.java | 4 ++-- .../typeinference/unify/TypeUnifyTask.java | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index b3884e07..54c3fb99 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -39,8 +39,8 @@ public class TypeUnify2Task extends TypeUnifyTask { return new HashSet<>(); } else */ - - noOfThread--; + //writeLog("xxx"); + //noOfThread--; synchronized (usedTasks) { if (this.myIsCancelled()) { return new HashSet<>(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 39f55184..8e940d70 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -904,9 +904,10 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { - noOfThread--; writeLog("wait "+ forkOrig.thNo); + noOfThread--; res = forkOrig.join(); + //noOfThread++; forkOrig.writeLog("final Orig 1"); forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); @@ -919,7 +920,9 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { + noOfThread--; Set> fork_res = fork.join(); + //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben writeLog("fork_res: " + fork_res.toString()); @@ -932,7 +935,7 @@ public class TypeUnifyTask extends RecursiveTask>> { fork.closeLogFile(); }; } - noOfThread++; + //noOfThread++; } else { if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) { Set forks = new HashSet<>(); @@ -1007,9 +1010,10 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { - noOfThread--; writeLog("wait "+ forkOrig.thNo); + noOfThread--; res = forkOrig.join(); + //noOfThread++; forkOrig.writeLog("final Orig -1"); forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); @@ -1022,7 +1026,9 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { + noOfThread--; Set> fork_res = fork.join(); + //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben writeLog("fork_res: " + fork_res.toString()); @@ -1035,7 +1041,7 @@ public class TypeUnifyTask extends RecursiveTask>> { fork.closeLogFile(); }; } - noOfThread++; + //noOfThread++; } else { if(parallel && (variance == 2) && noOfThread <= MaxNoOfThreads) { writeLog("var2einstieg"); @@ -1080,9 +1086,10 @@ public class TypeUnifyTask extends RecursiveTask>> { /* FORK ANFANG */ synchronized (this) { - noOfThread--; writeLog("wait "+ forkOrig.thNo); + noOfThread--; res = forkOrig.join(); + //noOfThread++; forkOrig.writeLog("final Orig 2"); forkOrig.closeLogFile(); //Set> fork_res = forkOrig.join(); @@ -1094,7 +1101,9 @@ public class TypeUnifyTask extends RecursiveTask>> { forks.forEach(x -> writeLog("wait: " + x.thNo)); for(TypeUnify2Task fork : forks) { synchronized (this) { + noOfThread--; Set> fork_res = fork.join(); + //noOfThread++; writeLog("Join " + new Integer(fork.thNo).toString()); //noOfThread--; an das Ende von compute verschoben add_res.add(fork_res); @@ -1102,7 +1111,7 @@ public class TypeUnifyTask extends RecursiveTask>> { fork.closeLogFile(); }; } - noOfThread++; + //noOfThread++; } else { //parallel = false; //Wenn MaxNoOfThreads erreicht ist, sequentiell weiterarbeiten elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859