001: //
002: // Copyright (C) 2005 United States Government as represented by the
003: // Administrator of the National Aeronautics and Space Administration
004: // (NASA). All Rights Reserved.
005: //
006: // This software is distributed under the NASA Open Source Agreement
007: // (NOSA), version 1.3. The NOSA has been approved by the Open Source
008: // Initiative. See the file NOSA-1.3-JPF at the top of the distribution
009: // directory tree for the complete NOSA document.
010: //
011: // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
012: // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
013: // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
014: // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
015: // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
016: // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
017: // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
018: //
019: package gov.nasa.jpf.jvm;
020:
021: import gov.nasa.jpf.util.HashData;
022:
023: /**
024: * this is the mutable Thread data we have to keep track of
025: */
026: class ThreadData {
027: /**
028: * Current state of the thread.
029: */
030: int status;
031:
032: /** the scheduler priority of this thread */
033: int priority = java.lang.Thread.NORM_PRIORITY;
034:
035: /**
036: * the name of this thread
037: * (only temporarily unset, between NEW and INVOKESPECIAL)
038: */
039: String name = "";
040:
041: /** is this a daemon thread */
042: boolean isDaemon;
043:
044: /**
045: * Class associated with the thread.
046: */
047: ClassInfo ci;
048:
049: /**
050: * The object reference that is the thread.
051: */
052: int objref;
053:
054: /**
055: * The object reference of the target object (if any).
056: */
057: int target = -1;
058:
059: /**
060: * The lock counter when the object got into a wait.
061: */
062: int lockCount;
063:
064: public Object clone() {
065: ThreadData t = new ThreadData();
066:
067: t.status = status;
068: t.ci = ci;
069: t.objref = objref;
070: t.target = target;
071: t.lockCount = lockCount;
072:
073: t.priority = priority;
074: t.name = name;
075: t.isDaemon = isDaemon;
076:
077: return t;
078: }
079:
080: public boolean equals(Object o) {
081: if ((o == null) || !(o instanceof ThreadData)) {
082: return false;
083: }
084:
085: ThreadData t = (ThreadData) o;
086:
087: return ((status == t.status) && (ci == t.ci)
088: && (objref == t.objref) && (target == t.target)
089: && (priority == t.priority) && (isDaemon == t.isDaemon)
090: && (lockCount == t.lockCount) && (name.equals(t.name)));
091: }
092:
093: public void hash(HashData hd) {
094: hd.add(status);
095: hd.add(objref);
096: hd.add(target);
097: hd.add(lockCount);
098: hd.add(priority);
099: hd.add(isDaemon);
100: hd.add(name);
101:
102: Boolean bo;
103: }
104:
105: public int hashCode() {
106: HashData hd = new HashData();
107:
108: hash(hd);
109:
110: return hd.getValue();
111: }
112:
113: public String toString() {
114: StringBuffer sb = new StringBuffer();
115:
116: sb.append("ThreadData(");
117: sb.append("status=");
118: sb.append(status);
119: sb.append(",ci=");
120:
121: if (ci == null) {
122: sb.append("null");
123: } else {
124: sb.append(ci.getName());
125: }
126:
127: sb.append(",objref=");
128: sb.append(objref);
129: sb.append(",target=");
130: sb.append(target);
131: sb.append(",priority=");
132: sb.append(priority);
133: sb.append(",name=");
134: sb.append(name);
135: sb.append(",lockCount=");
136: sb.append(lockCount);
137: sb.append(')');
138:
139: return sb.toString();
140: }
141: }
|