incubator-kato-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monte...@apache.org
Subject svn commit: r887268 - in /incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti: javaruntime/model/JMonitor.java javaruntime/model/JThread.java reader/CJVMTIBinReader.java
Date Fri, 04 Dec 2009 17:02:14 GMT
Author: monteith
Date: Fri Dec  4 17:02:13 2009
New Revision: 887268

URL: http://svn.apache.org/viewvc?rev=887268&view=rev
Log:
Add thread state and fixup monitors to use.

Modified:
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMonitor.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
    incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMonitor.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMonitor.java?rev=887268&r1=887267&r2=887268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMonitor.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JMonitor.java
Fri Dec  4 17:02:13 2009
@@ -38,9 +38,18 @@
 	@Override
 	public List<JavaThread> getEnterWaiters() {
 		List<JavaThread> waitingThreads= new LinkedList<JavaThread>();
-		for (Long l: waiters){
-			waitingThreads.add(model.getThread(l));
+		for (Long threadID: waiters){
+			JavaThread thread = model.getThread(threadID);
+			
+			try {
+				if ((thread.getState() & JavaThread.STATE_IN_OBJECT_WAIT)  == 0) {
+					waitingThreads.add(model.getThread(threadID));
+				}
+			} catch (CorruptDataException e) {
+				e.printStackTrace();
+			}
 		}
+
 		return waitingThreads;
 	}
 
@@ -61,11 +70,20 @@
 
 	@Override
 	public List<JavaThread> getNotifyWaiters() {
-		List<JavaThread> waitingThreads= new LinkedList<JavaThread>();
-		for (Long l: waiters){
-			waitingThreads.add(model.getThread(l));
+		List<JavaThread> objectWaitThreads= new LinkedList<JavaThread>();
+		for (Long threadID: waiters){
+			JavaThread thread = model.getThread(threadID);
+			
+			try {
+				if ((thread.getState() & JavaThread.STATE_IN_OBJECT_WAIT)  != 0) {
+					objectWaitThreads.add(model.getThread(threadID));
+				}
+			} catch (CorruptDataException e) {
+				e.printStackTrace();
+			}
 		}
-		return waitingThreads;
+		
+		return objectWaitThreads;
 	}
 
 	@Override

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java?rev=887268&r1=887267&r2=887268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/javaruntime/model/JThread.java
Fri Dec  4 17:02:13 2009
@@ -37,18 +37,89 @@
 	public JMonitor contendedMonitor=null;
 	public long id=0;
 	public short priority=0;
-	public  short daemon=0;
-	public int   groupID=0;
+	public short daemon=0;
+	public int groupID=0;
 	public String threadName=null;
 	private JObject object = null;
+	private int state=0; 
 
 	private List<JavaStackFrame> frames=new LinkedList<JavaStackFrame>();
-	
+
+	private final static int JVMTI_THREAD_STATE_ALIVE = 0x1;
+	private final static int JVMTI_THREAD_STATE_TERMINATED = 0x2;
+	private final static int JVMTI_THREAD_STATE_RUNNABLE = 0x4;
+	private final static int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x400;
+	private final static int JVMTI_THREAD_STATE_WAITING=0x80;
+	private final static int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x10;
+	private final static int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT=0x20;
+	private final static int JVMTI_THREAD_STATE_SLEEPING=0x40;
+	private final static int JVMTI_THREAD_STATE_IN_OBJECT_WAIT=0x100;
+	private final static int JVMTI_THREAD_STATE_PARKED=0x200;
+	private final static int JVMTI_THREAD_STATE_SUSPENDED=0x100000;
+	private final static int JVMTI_THREAD_STATE_INTERRUPTED=0x200000;
+	private final static int JVMTI_THREAD_STATE_IN_NATIVE=0x400000;
+	private final static int JVMTI_THREAD_STATE_VENDOR_1=0x10000000;
+	private final static int JVMTI_THREAD_STATE_VENDOR_2=0x20000000;
+	private final static int JVMTI_THREAD_STATE_VENDOR_3=0x40000000;
 	
 	public JThread(long id) {
 		this.id=id;
 	}
 
+	public void setState(int tiState) {
+		this.state =0;
+		if ((tiState & JVMTI_THREAD_STATE_ALIVE) != 0) {
+			state |= JavaThread.STATE_ALIVE;
+		}
+		
+	    if((tiState & JVMTI_THREAD_STATE_TERMINATED) != 0) {
+	    	state |= JavaThread.STATE_TERMINATED;
+	    }
+	    
+	    if((tiState & JVMTI_THREAD_STATE_RUNNABLE) != 0) {
+	    	state |= JavaThread.STATE_RUNNABLE;
+	    }
+	    if((tiState & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
+	    	state |= JavaThread.STATE_BLOCKED_ON_MONITOR_ENTER;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_WAITING) != 0) {
+	    	state |= JavaThread.STATE_WAITING;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) {
+	    	state |= JavaThread.STATE_WAITING_INDEFINITELY;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) {
+	    	state |= JavaThread.STATE_WAITING_WITH_TIMEOUT;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_SLEEPING) != 0) {
+	    	state |= JavaThread.STATE_SLEEPING;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_IN_OBJECT_WAIT) != 0) {
+	    	state |= JavaThread.STATE_IN_OBJECT_WAIT;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_PARKED) != 0) {
+	    	state |= JavaThread.STATE_PARKED;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_SUSPENDED) != 0) {
+	    	state |= JavaThread.STATE_SUSPENDED;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_INTERRUPTED) != 0) {
+	    	state |= JavaThread.STATE_INTERRUPTED;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_IN_NATIVE) != 0) {
+	    	state |= JavaThread.STATE_IN_NATIVE;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_VENDOR_1) != 0) {
+	    	state |= JavaThread.STATE_VENDOR_1;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_VENDOR_2) != 0) {
+	    	state |= JavaThread.STATE_VENDOR_2;
+		}
+	    if((tiState & JVMTI_THREAD_STATE_VENDOR_3) != 0) {
+	    	state |= JavaThread.STATE_VENDOR_3;
+		}
+	}
+	
 	@Override
 	public ImageThread getImageThread() throws CorruptDataException,
 			DataUnavailable {		
@@ -96,7 +167,7 @@
 	}
 	
 	@Override
-	public int getState() throws CorruptDataException {		
-		return STATE_ALIVE | STATE_RUNNABLE;
+	public int getState() throws CorruptDataException {
+		return state;
 	}
 }
\ No newline at end of file

Modified: incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java?rev=887268&r1=887267&r2=887268&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
(original)
+++ incubator/kato/trunk/org.apache.kato/kato.cjvmti/src/main/java/org/apache/kato/jvmti/reader/CJVMTIBinReader.java
Fri Dec  4 17:02:13 2009
@@ -1156,6 +1156,7 @@
 		t.groupID = 0;
 		t.priority = (short) variablesIn.readInt();
 		t.daemon = (short) variablesIn.readByte();
+		t.setState(variablesIn.readInt());
 		t.setObject((JObject) model.getObjectAtAddress(objectRef));
 		readMonitor(t);
 		readContendedMonitor(t);



Mime
View raw message