From 3fe5c4c308cf5a5e845f61ea971704fa9700fd7d Mon Sep 17 00:00:00 2001 From: adash Date: Thu, 3 Jan 2008 17:50:49 +0000 Subject: [PATCH] Add initial functions for thread join support --- .../src/Analysis/Locality/LocalityAnalysis.java | 16 ++++++++++++++-- Robust/src/ClassLibrary/Thread.java | 2 ++ Robust/src/ClassLibrary/ThreadDSM.java | 8 ++++++++ Robust/src/Runtime/thread.c | 7 +++++++ Robust/src/Tests/Atomic5.java | 2 +- 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index 1a7f5ce1..20a968b0 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -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); } diff --git a/Robust/src/ClassLibrary/Thread.java b/Robust/src/ClassLibrary/Thread.java index 3008a067..c44043bd 100644 --- a/Robust/src/ClassLibrary/Thread.java +++ b/Robust/src/ClassLibrary/Thread.java @@ -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(); + } diff --git a/Robust/src/ClassLibrary/ThreadDSM.java b/Robust/src/ClassLibrary/ThreadDSM.java index f6ba8cf3..322a022b 100644 --- a/Robust/src/ClassLibrary/ThreadDSM.java +++ b/Robust/src/ClassLibrary/ThreadDSM.java @@ -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); diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 235b4ed9..d306eceb 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -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; diff --git a/Robust/src/Tests/Atomic5.java b/Robust/src/Tests/Atomic5.java index b0160029..9d8f3377 100644 --- a/Robust/src/Tests/Atomic5.java +++ b/Robust/src/Tests/Atomic5.java @@ -8,7 +8,7 @@ public class Atomic5 extends Thread { Integer age; String name; - Atomic at5[]; + Atomic5 at5[]; atomic { at5[] = global new Atomic5[4]; } -- 2.34.1