harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r567096 - in /harmony/enhanced/drlvm/trunk: build/make/targets/ vm/gcv4/src/ vm/include/open/ vm/tests/unit/framework/ vm/tests/unit/thread/ vm/tests/unit/thread/utils/ vm/thread/src/ vm/thread/src/linux/ vm/vmcore/src/init/ vm/vmcore/src/j...
Date Fri, 17 Aug 2007 17:46:03 GMT
Author: wjwashburn
Date: Fri Aug 17 10:46:01 2007
New Revision: 567096

URL: http://svn.apache.org/viewvc?view=rev&rev=567096
Log:
Harmony-4608:  This is the first patch of the Thread Lifecycle
redesign document.


Removed:
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_private.h
Modified:
    harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
    harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml
    harmony/enhanced/drlvm/trunk/build/make/targets/test.xml
    harmony/enhanced/drlvm/trunk/vm/gcv4/src/gc_threads.cpp
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
    harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_fat_monitor.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_suspend.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml Fri Aug 17 10:46:01 2007
@@ -234,18 +234,5 @@
                 <linkerarg value="-lgcc_s" />
             </select>
         </linker>
-
-        <fileset id="unit.test.c.framework.src"
-                 dir="${build.VM.home}/tests/unit/framework">
-            <include name="*.c" />
-        </fileset>
-
-        <path id="unit.test.common.c.include">
-            <pathelement location="${build.VM.home}/tests/unit/framework" />
-            <pathelement location="${build.VM.home}/include" />
-            <pathelement location="${build.VM.home}/include/open" />
-            <pathelement location="${build.VM.home}/vmcore/src/thread" />
-            <pathelement location="${build.VM.home}/port/include" />
-        </path>
     </target>
 </project>

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml Fri Aug 17 10:46:01 2007
@@ -16,174 +16,215 @@
 -->
 <project name="C UNIT TESTS">
     <target name="cunit.test" depends="init_component">
+
+        <!-- Set cunit tests include dirs -->
         <path id="unit.test.c.include">
             <pathelement location="${build.VM.home}/tests/unit/thread/utils" />
+            <pathelement location="${build.VM.home}/tests/unit/framework" />
             <pathelement location="${build.semi.dir}/extra/apr/include" />
             <pathelement location="${build.semi.dir}/extra/apr/include/apr-1" />
+            <pathelement location="${build.VM.home}/include" />
             <pathelement location="${build.VM.home}/vmcore/include" />
+            <pathelement location="${build.VM.home}/port/include" />
         </path>
+
+        <!-- Set cunit tests sources -->
         <fileset id="unit.test.c.src" dir="${build.VM.home}/tests/unit/thread">
             <include name="*.c" />
-            <exclude name="*performance*"/>
         </fileset>
-        <!-- compiler to compile framework as well as the unit tests -->
-        <compiler name="${build.cxx}" id="unit.test.c.compiler">
-            <defineset define="APR_DECLARE_STATIC, _DEBUG, VM_STATS" />
-            <defineset define="BUILDING_VM" />
-            <select os="win">
-                <defineset define="PLATFORM_NT, WIN32, _WINDOWS" />
-                <defineset define="_WIN32_WINNT=0x0501" />
+
+        <!-- Create cunit tests work dir -->
+        <property name="unit.test.c.workdir" value="${build.dir}/_cunit.tests" />
+        <mkdir dir="${unit.test.c.workdir}/_obj" />
+        <mkdir dir="${unit.test.c.workdir}/_bin" />
+        <mkdir dir="${unit.test.c.workdir}/report" />
+
+        <compiler name="${build.cxx}" id="cunit.test.compiler">
+            <defineset define="APR_DECLARE_STATIC, BUILDING_VM"/>
+            <select cfg="release">
+                <defineset define="NDEBUG" />
+                <select os="win">
+                    <select cxx="icl">
+                        <compilerarg value="/QxN" />
+                        <compilerarg value="/O3" />
+                        <compilerarg value="/Qip" />
+                    </select>
+                    <select cxx="msvc">
+                        <compilerarg value="/Ox" />
+
+                    </select>
+                </select>
+                <select osfamily="unix">
+                    <compilerarg value="-O2" />
+                </select>
             </select>
-            <select os="lnx">
-                <defineset define="LINUX, GC_V4" />
-                <defineset define="USE_DLL_JIT, PLATFORM_POSIX" />
-                <defineset define="__SMP__, _REENTRANT" />
-                <defineset define="LINUX_TLS_OPT, _IA32_" />
-                <defineset define="_LARGEFILE64_SOURCE" />
-                <compilerarg value="-Wall" />
-                <compilerarg value="-fno-exceptions" />
-                <compilerarg value="-g" />
-                <compilerarg value="-O0" />
+ 
+            <select cfg="debug">
+                <defineset define="_DEBUG,VM_STATS" />
+                <select osfamily="unix">
+                    <compilerarg value="-O0" />
+                    <compilerarg value="-g" />
+                    <compilerarg value="-ggdb3" />
+                </select>
+                <select os="win" cxx="icl">
+                    <compilerarg value="/QxN" />
+                    <compilerarg value="/Qip" />
+                    <compilerarg value="/O3" />
+                </select>
             </select>
+
             <select arch="ia32">
                 <defineset define="_IA32_" />
             </select>
+            <select arch="ipf">
+                <defineset define="_IPF_,POINTER64,HYIA64" />
+            </select>
             <select arch="em64t">
-                <defineset define="_EM64T_" />
-                <defineset define="POINTER64" />
-                <defineset define="LAZY_LOCK" />
+                <defineset define="_EM64T_,POINTER64,LAZY_LOCK,HYX86_64" />
+            </select>
+            <select arch="ppc32">
+                <defineset define="_PPC32_,_PPC_,HYPPC32" />
+            </select>
+            <select os="win">
+                <defineset define="PLATFORM_NT,WIN32,_WINDOWS" />
+                <defineset>
+                    <define name="_WIN32_WINNT" value="0x0501" />
+                </defineset>
+                <compilerarg value="/nologo" />
+                <compilerarg value="/W3" />
+                <select arch="ia32,ipf">
+                    <compilerarg value="/WX" />
+                </select>
+                <compilerarg value="/Zi" />
+            </select>
+            <select osfamily="unix">
+                <defineset define="PLATFORM_POSIX" />
+                <compilerarg value="-fno-exceptions" />
+                <select os="macosx">
+                    <defineset define="MACOSX" />
+                </select>
+                <select os="lnx">
+                    <defineset define="LINUX" />
+                </select>
+                <defineset define="__SMP__,_REENTRANT,LINUX_TLS_OPT" />
+                <select arch="em64t">
+                    <compilerarg value="-ftls-model=initial-exec" /> 
+                </select>
+                <select arch="ia32">
+                    <defineset define="_LARGEFILE64_SOURCE" />
+                </select>
+                <select os="lnx" arch="em64t,ipf">
+                    <compilerarg value="-fPIC" />
+                </select>
+                <select cxx="icc">
+                    <compilerarg value="-w1" />
+                </select>
+            </select>
+            <select cxx="icc,icl">                  
+                <compilerarg value="-mp" />
             </select>
         </compiler>
-        <!-- Compiling framework -->
-        <echo message="## Compiling framework..." />
-        <!-- a new property: cunit tests work dir -->
-        <property name="unit.test.c.workdir"
-                          value="${build.dir}/_cunit.tests" />
-        <mkdir dir="${unit.test.c.workdir}/_obj" />
-        <cc objdir="${unit.test.c.workdir}/_obj"
-                    debug="true"
-                    runtime="static"
-                    multithreaded="true">
-            <compiler refid="unit.test.c.compiler" />
-            <fileset refid="unit.test.c.framework.src" />
+       
+        <!-- Compiling cunit tests and framework -->
+        <echo message="cunit: Compiling tests and framework..." />
+        <cc objdir="${unit.test.c.workdir}/_obj" multithreaded="true">
+            <compiler refid="cunit.test.compiler" />
             <fileset dir="${build.VM.home}/tests/unit/thread/utils">
                 <include name="*.c" />
             </fileset>
-            <includepath refid="unit.test.common.c.include" />
+            <fileset dir="${build.VM.home}/tests/unit/framework">
+                <include name="*.c" />
+            </fileset>
+            <fileset refid="unit.test.c.src"/>
             <includepath refid="unit.test.c.include" />
         </cc>
-        <!-- a list of all source files with unit tests -->
-        <pathconvert pathsep=","
-                             property="unit.test.c.files"
-                             refid="unit.test.c.src" />
-        <!-- operation system sensitive executive binary file extention.
-                     simply said: "" or ".exe" ;) -->
+        
+        <!-- Create a list of cunit tests excecutable -->
+        <pathconvert pathsep="," property="unit.test.c.files" refid="unit.test.c.src" />
+        <propertyregex override="yes" property="unit.test.c.files" input="${unit.test.c.files}"
+            regexp="\.c" replace="" defaultValue="${unit.test.c.files}" />
         <condition property="extention" value=".exe">
             <isset property="if.win" />
         </condition>
         <property name="extention" value="" />
-        <!-- replacing: 'xxx.c, yyy.c' => 'xxx yyy' -->
-        <propertyregex override="yes"
-                               property="unit.test.c.files"
-                               input="${unit.test.c.files}"
-                               regexp="\.c"
-                               replace=""
-                               defaultValue="${unit.test.c.files}" />
-        <!-- Compiling unit tests -->
-        <echo message="## Compiling C unit tests" />
-        <cc objdir="${unit.test.c.workdir}/_obj"
-                    debug="true"
-                    runtime="static"
-                    multithreaded="true" 
-                    subsystem="console">
-            <compiler refid="unit.test.c.compiler" />
-            <fileset refid="unit.test.c.src" />
-            <includepath refid="unit.test.common.c.include" />
-            <includepath refid="unit.test.c.include" />
-        </cc>
-        <mkdir dir="${unit.test.c.workdir}/_bin" />
 
-        <mkdir dir="${unit.test.c.workdir}/report" />
-        <!-- set of properties which will be needed for test execution -->
+        <!-- Compiling cunit tests -->
         <property name="filename" value="--" />
-        <property name="outputproperty" value="--" />
-        <property name="resultproperty" value="--" />
+
+        <echo message="cunit: Compiling tests..." />
         <for list="${unit.test.c.files}" param="file" delimiter=",">
             <sequential>
-                <!-- make it possible to overwrite the property -->
+
                 <var name="filename" unset="true" />
                 <basename property="filename" file="@{file}" />
-                <!-- Linking unit test -->
-                <echo message="## Linking C unit test: ${filename}" />
-                <cc name="${build.cxx}"
-                            debug="true"
-                            outfile="${unit.test.c.workdir}/_bin/${filename}"
-                            outtype="executable" 
-                            subsystem="console">
+
+                <echo message="cunit: Compile test: ${filename}" />
+                
+                <cc outfile="${unit.test.c.workdir}/_bin/${filename}${extention}"
+                    runtime="dynamic" multithreaded="true" subsystem="console">
+                    
+                    <compiler refid="cunit.test.compiler" />
+                    
                     <linker name="${build.cxx}">
                         <fileset dir="${unit.test.c.workdir}/_obj">
-                            <include name="${filename}.o*" />
                             <include name="thread_unit_test_main.o*" />
                             <include name="thread_unit_test_utils.o*" />
                             <include name="testframe.o*" />
+                            <include name="${filename}.o*" />
                         </fileset>
 
-                        <libset libs="hythr" dir="${build.semi.dir}/vm/hythr/_bin" />
-                        <libset libs="encoder" dir="${build.semi.dir}/vm/encoder/_bin" />
-                        <libset libs="aprutil-1" dir="${build.semi.dir}/extra/aprutil/_bin" />
-                        <libset libs="port" dir="${build.semi.dir}/vm/port/_bin" />
-                        <libset libs="log4cxx" dir="${build.semi.dir}/extra/log4cxx/_bin" />
-                        <libset libs="hyzlib" dir="${external.dep.CLASSLIB}/deploy/jdk/jre/bin" />
-                        <libset libs="harmonyvm" dir="${build.semi.dir}/vm/vmcore/_bin" />
-                        <libset libs="icuuc" dir="${external.dep.CLASSLIB.libdir}" />
                         <select os="win">
-                            <syslibset libs="advapi32, ws2_32, mswsock, user32, userenv, odbc32" />
-                            <linkerarg value="/NODEFAULTLIB:libcmt.lib" />
+                            <libset type="shared" libs="harmonyvm"
+                                dir="${build.semi.dir}/vm/vmcore/_bin" />
+                            <libset type="shared" libs="hythr"
+                                dir="${build.semi.dir}/vm/hythr/_bin" />
+                            <linkerarg value="/libpath:${build.deploy.dir}/jdk/jre/bin/default" />
+                            <linkerarg value="/NODEFAULTLIB:libcmtd" />
                         </select>
+                        
                         <select os="lnx">
-                            <syslibset type="shared" libs="stdc++, gcc_s, pthread, rt" />
-                            <select arch="ia32">
-                                <libset type="shared" libs="icuuc" />
-                                <libset type="shared" libs="icudata"
-                                    dir="${external.dep.CLASSLIB}/depends/libs/linux.x86" />
-                                </select>               
-                            <select arch="em64t">
-                                <libset type="shared" libs="icuuc"
-                                    dir="${external.dep.CLASSLIB}/depends/libs/linux.x86_64" />
-                                <libset type="shared" libs="icudata"
-                                    dir="${external.dep.CLASSLIB}/depends/libs/linux.x86_64" />
-                            </select>
-                            <select arch="ipf">
-                                <libset type="shared" libs="icuuc"
-                                    dir="${external.dep.CLASSLIB}/depends/libs/linux.ia64" />
-                                <libset type="shared" libs="icudata"
-                                    dir="${external.dep.CLASSLIB}/depends/libs/linux.ia64" />
-                            </select>
+                            <libset type="shared" libs="harmonyvm"
+                                dir="${build.deploy.dir}/jdk/jre/bin/default" />
+                            <linkerarg value="-rpath" />
+                            <linkerarg value="${build.deploy.dir}/jdk/jre/bin" />
+                            <linkerarg value="-rpath" />
+                            <linkerarg value="${build.deploy.dir}/jdk/jre/bin/default" />
                         </select>
                     </linker>
                 </cc>
             </sequential>
         </for>
-        
+                    
+        <!-- Executing cunit tests... -->
+        <property name="outputproperty" value="--" />
+        <property name="resultproperty" value="--" />
         <delete file="${build.semi.dir}/cunit.test.failed" failonerror="false" />
-            
+
+        <echo message="cunit: Compiling tests..." />
         <for list="${unit.test.c.files}" param="file" delimiter=",">
             <sequential>
-                <!-- make it possible to overwrite the property -->
+                
                 <var name="filename" unset="true" />
                 <basename property="filename" file="@{file}" />
-                <!-- Executing unit test -->
-                <echo message="## Executing C unit test: ${filename}" />
+                
+                <!-- Executing unit test... -->
+                <echo message="cunit: Executing test: ${filename} ..." />
                 <var name="outputproperty" unset="true" />
                 <var name="resultproperty" unset="true" />
                 <exec dir="${unit.test.c.workdir}/_bin"
-                              executable="${unit.test.c.workdir}/_bin/${filename}${extention}"
-                              resultproperty="resultproperty"
-                              outputproperty="outputproperty">
+                    executable="${unit.test.c.workdir}/_bin/${filename}${extention}"
+                    resultproperty="resultproperty"
+                    outputproperty="outputproperty">
+                    
                     <arg value="-Dorg.apache.harmony.vm.vmdir=${build.deploy.dir}/jdk/jre/bin/default"/>
                     <arg value="-Djava.home=${build.deploy.dir}/jdk/jre ${test.vmargs}"/>
                     <arg value="-XX:vm.jvmti.enabled=true"/>
+                    <select arch="ipf">
+                        <arg value="-Xint"/>
+                    </select>
+                    
                     <env key="JAVA_HOME" value="${build.deploy.dir}/jdk/jre" />
+                    
                     <select os="win">
                         <env key="Path" path="${build.deploy.dir}/jdk/jre/bin/:${build.deploy.dir}/jdk/jre/bin/default:${env.Path}" />
                     </select>
@@ -191,38 +232,47 @@
                         <env key="LD_LIBRARY_PATH" path="${build.deploy.dir}/jdk/jre/bin/:${build.deploy.dir}/jdk/jre/bin/default" />
                     </select>
                 </exec>
-                <echo file="${unit.test.c.workdir}/report/${filename}.out"
-                              message="${outputproperty}" />
-                <echo message="${outputproperty}" />
+
+                <!-- Echo test output... -->
+                <echo file="${unit.test.c.workdir}/report/${filename}.out" message="${outputproperty}" />
+                <!-- echo message="${outputproperty}" / -->
+
+                <!-- Checking test result... -->
                 <if>
                     <not>
                         <equals arg1="${resultproperty}" arg2="0" />
                     </not>
                     <then>
+                        
+                        <!-- Test failed... -->
                         <property name="test.failed" value="true" />
-                        <echo message="## TEST FAILED" />
+                        <echo message="cunit: TEST FAILED" />
                         <echo file="${build.semi.dir}/cunit.test.failed" message="${filename} FAILED${line.separator}" append="true"/>
 
-<echo file="${unit.test.c.workdir}/report/TEST-${filename}.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="1" name="@@@@@" tests="1" time="0.01">
-<testcase classname="@@@@@" name="test" time="0.1"><error message="FAILED"/></testcase>
-<system-out><![CDATA[@out]!]></system-out>
-</testsuite>]]> 
-</echo>
+                        <echo file="${unit.test.c.workdir}/report/TEST-${filename}.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
+                            <testsuite errors="0" failures="1" name="@@@@@" tests="1" time="0.01">
+                                <testcase classname="@@@@@" name="test" time="0.1"><error message="FAILED"/></testcase>
+                                <system-out><![CDATA[@out]!]></system-out>
+                            </testsuite>]]>
+                        </echo>
 
                     </then>
                     <else>
-                        <echo message="## TEST PASSED" />
-<echo file="${unit.test.c.workdir}/report/TEST-${filename}.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" failures="0" name="@@@@@" tests="1" time="0.01">
-<testcase classname="@@@@@" name="test" time="0.1"></testcase>
-<system-out><![CDATA[@out]!]></system-out>
-</testsuite>]]> 
-</echo>
+                        
+                        <!-- Test passed... -->
+                        <echo message="cunit: TEST PASSED" />
+                        <echo file="${unit.test.c.workdir}/report/TEST-${filename}.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
+                            <testsuite errors="0" failures="0" name="@@@@@" tests="1" time="0.01">
+                                <testcase classname="@@@@@" name="test" time="0.1"></testcase>
+                                <system-out><![CDATA[@out]!]></system-out>
+                            </testsuite>]]>
+                        </echo>
+                        
                     </else>
                 </if>
-                <replace file="${unit.test.c.workdir}/report/TEST-${filename}.xml" token="@@@@@" value="${filename}" /> 
-                <!-- grab System.out to xml-file -->
+
+                <!-- Setting file output to xml... -->
+                <replace file="${unit.test.c.workdir}/report/TEST-${filename}.xml" token="@@@@@" value="${filename}" />
                 <if>
                     <isset property="outputproperty" />
                     <then>
@@ -235,6 +285,7 @@
             </sequential>
         </for>
 
+        <!-- Creating execution report... -->
         <property name="cunit.tests.report.dir" location="${unit.test.c.workdir}/report/html"/>
         <delete dir="${cunit.tests.report.dir}" />
         <mkdir dir="${cunit.tests.report.dir}" />
@@ -246,6 +297,7 @@
         </junitreport>
 
         <echo message="## Please find tests and results at ${build.dir}/_cunit.tests/" />
-        <fail unless="run.all.tests" if="test.failed" message="## SOME TESTS FAILED"/>
+        <fail unless="run.all.tests" if="test.failed" message="cunit: SOME TESTS FAILED"/>
     </target>
 </project>
+

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/test.xml?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/test.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/test.xml Fri Aug 17 10:46:01 2007
@@ -17,7 +17,7 @@
 <project name="ALL TESTS">
     <select arch="ipf">
         <propertyregex property="test.mode" input="${test.mode}" regexp="(jet|opt|srv)" replace="" override="on" />
-        <target name="test" depends="smoke.test, kernel.test, check-result"/>
+        <target name="test" depends="cunit.test, smoke.test, kernel.test, check-result"/>
     </select>
     <select arch="ia32,em64t">
         <target name="test" depends="jvmti.test, cunit.test, smoke.test, kernel.test, check-result"/>

Modified: harmony/enhanced/drlvm/trunk/vm/gcv4/src/gc_threads.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gcv4/src/gc_threads.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gcv4/src/gc_threads.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gcv4/src/gc_threads.cpp Fri Aug 17 10:46:01 2007
@@ -123,7 +123,7 @@
     stat = hysem_create(&_gc_thread_work_done_event, 0, 1); 
     assert(stat == TM_ERROR_NONE);
     _thread_handle=NULL;
-    stat = hythread_create_with_group(&_thread_handle, get_thread_group(), 0, 0, 0, gc_thread_func, this);
+    stat = hythread_create(&_thread_handle, 0, 0, 0, gc_thread_func, this);
     if (stat != TM_ERROR_NONE) { 
         DIE("GC_Thread::GC_Thread(..): CreateThread() failed...exiting...");
     }

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Fri Aug 17 10:46:01 2007
@@ -189,9 +189,8 @@
  */
 //@{
 
-IDATA VMCALL hythread_attach_ex(hythread_t *handle, hythread_library_t lib);
-IDATA VMCALL hythread_attach_to_group(hythread_t *handle, hythread_library_t lib, hythread_group_t group);
-IDATA hythread_create_with_group(hythread_t *ret_thread, hythread_group_t group, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data);
+IDATA VMCALL hythread_create_with_group(hythread_t new_thread, hythread_group_t group, UDATA stacksize, UDATA priority, hythread_entrypoint_t func, void *data);
+IDATA VMCALL hythread_attach_to_group(hythread_t new_handle, hythread_library_t lib, hythread_group_t group);
 UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread);
 IDATA VMCALL hythread_join(hythread_t t);
 IDATA VMCALL hythread_join_timed(hythread_t t, I_64 millis, IDATA nanos);
@@ -199,7 +198,7 @@
 IDATA VMCALL hythread_get_self_id();
 IDATA VMCALL hythread_get_id(hythread_t t);
 hythread_t VMCALL hythread_get_thread(IDATA id);
-IDATA VMCALL hythread_struct_init(hythread_t *ret_thread);
+IDATA VMCALL hythread_struct_init(hythread_t new_thread);
 IDATA VMCALL hythread_cancel_all(hythread_group_t group);
 IDATA hythread_group_create(hythread_group_t *group);
 IDATA VMCALL hythread_group_release(hythread_group_t group);
@@ -211,6 +210,7 @@
 UDATA hythread_get_thread_stacksize(hythread_t thread);
 UDATA VMCALL hythread_uses_fast_tls(void);
 IDATA VMCALL hythread_get_hythread_offset_in_tls(void);
+IDATA VMCALL hythread_get_struct_size();
 
 IDATA VMCALL hythread_thread_lock(hythread_t thread);
 IDATA VMCALL hythread_thread_unlock(hythread_t thread);

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/framework/testframe.h Fri Aug 17 10:46:01 2007
@@ -22,6 +22,8 @@
 #ifndef _TESTFRAME_H_
 #define _TESTFRAME_H_
 
+#include <stdlib.h>
+
 #ifdef  __cplusplus
 extern "C" {
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c Fri Aug 17 10:46:01 2007
@@ -67,7 +67,7 @@
     tested_thread_sturct_t * tts;
 
     // Initialize tts structures and run all tested threads
-    tested_os_threads_run(run_for_test_jthread_attach);
+    tested_os_threads_run((hythread_entrypoint_t)run_for_test_jthread_attach);
     
     // Make second attach to the same jthread.
     reset_tested_thread_iterator(&tts);
@@ -222,7 +222,7 @@
     } else {
         // wait until timeout or previous thread ends 
         status = jthread_timed_join(prev_tts->java_thread, timed_join_wait_time, 0);
-        printf("-------- status = %08x (%i) %i\n", status,  status, timed_join_wait_time);
+        printf("-------- status = %#08x (%d) %d\n", (int)status, (int)status, timed_join_wait_time);
         tts->phase = TT_PHASE_DEAD;
         if (timed_join_wait_time > CLICK_TIME_MSEC * 10){
             // must be thread end

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c Fri Aug 17 10:46:01 2007
@@ -40,8 +40,8 @@
 int test_hythread_create(void){
     apr_pool_t *pool;
     void **args; 
-    hythread_t thread = NULL;
-    int r;
+    hythread_t thread;
+    IDATA r;
     
     apr_pool_create(&pool, NULL);
 
@@ -53,7 +53,10 @@
     ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
     ((jthread_threadattr_t *)args[1])->priority  = 1;
     
-    r = hythread_create_with_group(&thread, args[0], 1024000, 1, 0, start_proc, args);
+    thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    assert(thread);
+    r = hythread_create_with_group(thread, args[0], 1024000, 1,
+        (hythread_entrypoint_t)start_proc, args);
     tf_assert(r == 0 && "thread creation failed");
 
     r = hythread_join(thread);
@@ -107,8 +110,10 @@
     hylatch_create(&end, 1);
 
     for (i = 0; i < n; i++) {
-        thread = NULL;
-        hythread_create_with_group(&thread, group, 0, 0, 0, start_proc_empty, NULL);
+        thread = (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(thread);
+        hythread_create_with_group(thread, group, 0, 0,
+            (hythread_entrypoint_t)start_proc_empty, NULL);
     }
 
     // Wait util all threads have started.
@@ -117,7 +122,7 @@
     // Notify all threads
     hylatch_count_down(end);
 
-    printf ("iterator size: %d\n", hythread_iterator_size(iterator));
+    printf ("iterator size: %d\n", (int)hythread_iterator_size(iterator));
     tf_assert(hythread_iterator_size(iterator) == n);
     i = 0;
     while(hythread_iterator_has_next(iterator)) {
@@ -145,8 +150,10 @@
     hylatch_create(&end, 1);
 
     for (i = 0; i < n; i++) {
-        thread = NULL;
-        hythread_create(&thread, 0, 0, 0, start_proc_empty, NULL);
+        thread = (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(thread);
+        hythread_create_with_group(thread, NULL, 0, 0,
+            (hythread_entrypoint_t)start_proc_empty, NULL);
     }
 
     // Wait util all threads have started.
@@ -155,7 +162,7 @@
     // Notify all threads
     hylatch_count_down(end);
 
-    printf("default group iterator: %d\n", hythread_iterator_size(iterator));
+    printf("default group iterator: %d\n", (int)hythread_iterator_size(iterator));
     tf_assert(hythread_iterator_size(iterator) >= n);
     i = 0;
     while(hythread_iterator_has_next(iterator)) {
@@ -182,7 +189,7 @@
     void **args; 
     hythread_t thread = NULL;
     hythread_group_t group = NULL;
-    int r;
+    IDATA r;
     
     char *buf;
     int i = 10;
@@ -199,9 +206,10 @@
         ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
         ((jthread_threadattr_t *)args[1])->priority  = 1;
         
-        thread = NULL;
-
-        r = hythread_create_with_group(&thread, group, 1024000, 1, 0, start_proc, args);
+        thread = (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(thread);
+        r = hythread_create_with_group(thread, group, 1024000, 1,
+            (hythread_entrypoint_t)start_proc, args);
         tf_assert(r == 0 && "thread creation failed");
         buf = (char *)apr_pcalloc(pool, sizeof(char)*12);
 

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_fat_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_fat_monitor.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_fat_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_fat_monitor.c Fri Aug 17 10:46:01 2007
@@ -60,8 +60,10 @@
     waiting_count = 0;
 
     for (i = 0; i < NMB; i++){
-        threads[i] = NULL;
-        hythread_create(&threads[i], 0, 0, 0, run_for_test_wait_signal, NULL);
+        threads[i] = (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(threads[i]);
+        hythread_create_with_group(threads[i], NULL, 0, 0,
+            (hythread_entrypoint_t)run_for_test_wait_signal, NULL);
     }
 
     // Wait till all tested threads call wait() 

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_suspend.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_suspend.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_suspend.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_suspend.c Fri Aug 17 10:46:01 2007
@@ -28,7 +28,7 @@
 int test_hythread_thread_suspend(void){
     apr_pool_t *pool;
     void **args; 
-    hythread_t thread = NULL;
+    hythread_t thread;
     hythread_thin_monitor_t lockword_ptr;
     IDATA status;
     int i;
@@ -41,7 +41,10 @@
 
     args[0] = &lockword_ptr;
     args[1] = 0;
-    hythread_create(&thread, 0, 0, 0, start_proc, args);
+    thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    assert(thread);
+    hythread_create_with_group(thread, NULL, 0, 0,
+        (hythread_entrypoint_t)start_proc, args);
     hythread_sleep(500); 
     hythread_suspend_other(thread);
     hythread_suspend_disable();
@@ -63,7 +66,7 @@
     
     hythread_join(thread);
     
-    tf_assert_same((int)args[1], 1);
+    tf_assert_same((IDATA)args[1], 1);
 
     return 0;
 }
@@ -86,8 +89,10 @@
     args[0] = lockword_ptr;
     args[1] = 0;
     for(i = 0; i < 10; i++) {
-        thread = NULL;
-        hythread_create(&thread, 0, 0, 0, start_proc, args);
+        thread = (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(thread);
+        hythread_create_with_group(thread, NULL, 0, 0,
+            (hythread_entrypoint_t)start_proc, args);
     } 
     hythread_sleep(500); 
     hythread_suspend_all(NULL, ((HyThread_public*)hythread_self())->group);

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c Fri Aug 17 10:46:01 2007
@@ -106,7 +106,7 @@
     tf_assert_same(status, TM_ERROR_NONE);
 
     status = hythread_thin_monitor_wait_timed(&lockword_ptr, 1000,100);
-    printf("status: %d\n", status);
+    printf("status: %d\n", (int)status);
     tf_assert_same(status, TM_ERROR_TIMEOUT);
 
     status = hythread_thin_monitor_exit(&lockword_ptr);
@@ -119,7 +119,7 @@
 int test_hythread_thin_monitor_enter_contended(void){
     apr_pool_t *pool;
     void **args; 
-    hythread_t thread = NULL;
+    hythread_t thread;
     hythread_thin_monitor_t lockword_ptr;
     IDATA status;
     int i;
@@ -137,7 +137,10 @@
 
     args[0] = &lockword_ptr;
     args[1] = 0;
-    status = hythread_create(&thread, 0, 0, 0, start_proc, args);
+    thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    assert(thread);
+    status = hythread_create_with_group(thread, NULL, 0, 0,
+        (hythread_entrypoint_t)start_proc, args);
     tf_assert_same(status, TM_ERROR_NONE);
     for(i = 0; i < 100000; i++) {
         tf_assert_same(args[1], 0);
@@ -153,9 +156,9 @@
     status = hythread_thin_monitor_enter(&lockword_ptr);
     tf_assert_same(status, TM_ERROR_NONE);
     args[1] = 0;
-    thread = NULL;
     hythread_suspend_enable();    
-    status = hythread_create(&thread, 0, 0, 0, start_proc, args);
+    status = hythread_create_with_group(thread, NULL, 0, 0,
+        (hythread_entrypoint_t)start_proc, args);
     tf_assert_same(status, TM_ERROR_NONE);
     for(i = 0; i < 100000; i++) {
         tf_assert_same(args[1], 0);
@@ -167,7 +170,7 @@
 
     hythread_join(thread);
     
-    tf_assert_same((int)args[1], 1);
+    tf_assert_same((IDATA)args[1], 1);
 
     return 0;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c Fri Aug 17 10:46:01 2007
@@ -19,11 +19,11 @@
 #include "jni.h"
 #include "testframe.h"
 #include "thread_unit_test_utils.h"
-#include <open/jthread.h>
-#include <open/hythread.h>
-#include <open/hythread_ext.h>
-#include <open/ti_thread.h>
-#include <open/thread_externals.h>
+#include "open/jthread.h"
+#include "open/hythread.h"
+#include "open/hythread_ext.h"
+#include "open/ti_thread.h"
+#include "open/thread_externals.h"
 #include "apr_time.h"
 
 
@@ -269,10 +269,11 @@
     reset_tested_thread_iterator(&tts);
     while(next_tested_thread(&tts)){
         // Create thread
-        status = hythread_create(&tts->native_thread,  // new thread OS handle 
-                                 0, 5, 0,
-                                 run_method_param, // start proc
-                                 tts); 
+        tts->native_thread =
+            (hythread_t)calloc(1, hythread_get_struct_size());
+        assert(tts->native_thread);
+        status = hythread_create_with_group(tts->native_thread,
+            NULL, 0, 5, run_method_param, tts);
         tf_assert_v(status == TM_ERROR_NONE);
         tested_thread_wait_started(tts);
     }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h Fri Aug 17 10:46:01 2007
@@ -15,6 +15,7 @@
  *  limitations under the License.
  */
 
+#include <stdlib.h>
 #include "jvmti_types.h"
 #include "apr_thread_proc.h"
 #include "open/hycomp.h"

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Fri Aug 17 10:46:01 2007
@@ -1,4 +1,4 @@
-LIBRARY	HYTHR
+LIBRARY HYTHR
 
 EXPORTS
  
@@ -40,6 +40,7 @@
 hythread_tls_get
 hythread_tls_get_request_offset
 hythread_tls_get_offset
+hythread_get_struct_size
 hythread_global_lock
 hythread_global_unlock
 hythread_attach_to_group
@@ -88,9 +89,6 @@
 hythread_native_resource_is_live
 hythread_reclaim_resources
 
-
-
-
 hysem_post
 hysem_wait
 hysem_destroy
@@ -120,7 +118,6 @@
 hymutex_trylock
 hymutex_unlock
 hymutex_destroy
-
 
 hythread_is_alive
 hythread_is_terminated

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Fri Aug 17 10:46:01 2007
@@ -41,6 +41,7 @@
 hythread_get_hythread_offset_in_tls;
 hythread_uses_fast_tls;
 hythread_tls_get_offset;
+hythread_get_struct_size;
 hythread_global_lock;
 hythread_global_unlock;
 hythread_attach_to_group;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Fri Aug 17 10:46:01 2007
@@ -50,23 +50,23 @@
         int (VMAPICALL *func)(void*), void *data)
 {
     pthread_t thread;
-    pthread_attr_t attr, *pattr = NULL;
+    pthread_attr_t attr;
     int r;
 
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
     if (stacksize != 0) {
-	pattr = &attr;
-	pthread_attr_init(pattr);
-	r = pthread_attr_setstacksize(pattr, stacksize);
+	r = pthread_attr_setstacksize(&attr, stacksize);
 	if (r) {
-	    pthread_attr_destroy(pattr);
+	    pthread_attr_destroy(&attr);
 	    return r;
 	}
     }
 
-    r = pthread_create(&thread, pattr, (void*(*)(void*))func, data);
+    r = pthread_create(&thread, &attr, (void*(*)(void*))func, data);
 
-    if (pattr)
-	pthread_attr_destroy(pattr);
+    pthread_attr_destroy(&attr);
 
     if (r == 0) {
         *phandle = thread;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c Fri Aug 17 10:46:01 2007
@@ -73,8 +73,6 @@
  * @param[out] lib pointer to the created thread library
  * @return The thread library's initStatus will be set to 0 on success or 
  * a negative value on failure.
- * 
- * @see hythread_attach, hythread_shutdown
  */
 IDATA VMCALL hythread_lib_create(hythread_library_t * lib) {
     apr_status_t apr_status;
@@ -121,8 +119,6 @@
  * @param[in] lib pointer to the thread library to be initialized (non-NULL)
  * @return The thread library's initStatus will be set to 0 on success or 
  * a negative value on failure.
- * 
- * @see hythread_attach, hythread_shutdown
  */
 void VMCALL hythread_init(hythread_library_t lib) {
     apr_status_t apr_status;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Fri Aug 17 10:46:01 2007
@@ -47,8 +47,6 @@
 extern hythread_group_t TM_DEFAULT_GROUP;
 extern hythread_library_t TM_LIBRARY;
 static int VMAPICALL thread_start_proc(void *arg);
-static hythread_t allocate_thread();
-static void reset_thread(hythread_t thread);
 static IDATA register_to_group(hythread_t thread, hythread_group_t group);
 
 #define NAKED __declspec(naked)
@@ -98,30 +96,28 @@
  * @param[in] func function to run in the new thread
  * @param[in] data argument to be passed to starting function
  */
-IDATA VMCALL hythread_create_with_group(hythread_t *ret_thread, hythread_group_t group, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) {
-    hythread_t  new_thread;
+IDATA VMCALL hythread_create_with_group(hythread_t new_thread,
+                                        hythread_group_t group,
+                                        UDATA stacksize,
+                                        UDATA priority,
+                                        hythread_entrypoint_t func,
+                                        void *data)
+{
+    int result;
+    hythread_t self;
     thread_start_proc_data * start_proc_data;
-    int r;
-   
-    if (ret_thread) {
-        hythread_struct_init(ret_thread);
-        new_thread = *ret_thread;
-    } else {
-        new_thread = allocate_thread();
-    }
-    
-    if (new_thread == NULL) {
-        return TM_ERROR_OUT_OF_MEMORY;
-    }
 
-    new_thread->library = hythread_self()->library;
+    assert(new_thread);
+    hythread_struct_init(new_thread);
+
+    self = hythread_self();
+    new_thread->library = self ? self->library : TM_LIBRARY;
     new_thread->priority = priority ? priority : HYTHREAD_PRIORITY_NORMAL;
     new_thread->stacksize = stacksize ? stacksize : TM_DEFAULT_STACKSIZE;
-    //new_thread->suspend_request = suspend ? 1 : 0;
     
+    // No need to zero allocated memory because all fields are initilized below.
     start_proc_data =
         (thread_start_proc_data *) malloc(sizeof(thread_start_proc_data));
-
     if (start_proc_data == NULL) {
         return TM_ERROR_OUT_OF_MEMORY;
     }
@@ -132,15 +128,15 @@
     start_proc_data->start_proc = func;
     start_proc_data->start_proc_args = data;
 
-    // we need to make sure thread will not register itself with a thread group
-    // until os_thread_create returned and initialized thread->os_handle properly
+    // Need to make sure thread will not register itself with a thread group
+    // until os_thread_create returned and initialized thread->os_handle properly.
     hythread_global_lock();
-    r = os_thread_create(&new_thread->os_handle, new_thread->stacksize,
+    result = os_thread_create(&new_thread->os_handle, new_thread->stacksize,
             priority, thread_start_proc, (void *)start_proc_data);
-    assert(/* error */ r || new_thread->os_handle /* or thread created ok */);
+    assert(/* error */ result || new_thread->os_handle /* or thread created ok */);
     hythread_global_unlock();
    
-    return r;
+    return result;
 }
 
 /**
@@ -164,48 +160,47 @@
  *
  * @see hythread_exit, hythread_resume
  */
-IDATA VMCALL hythread_create(hythread_t *ret_thread, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) {
-    return hythread_create_with_group(ret_thread, NULL, stacksize, priority, suspend, func, data);
+IDATA VMCALL hythread_create(hythread_t *handle, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) {
+    hythread_t thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    assert(thread);
+    if (handle) {
+        *handle = thread;
+    }
+    return hythread_create_with_group(thread, NULL, stacksize, priority, func, data);
 }
 
 /**
  * Registers the current OS thread with the threading subsystem.
  *
- * @param[in] handle thread to register
- * @param[in] lib thread library to attach to
- * @param[in] group thread group, or NULL; in case of NULL this thread will go to the default group
- */
-IDATA hythread_attach_to_group(hythread_t * handle, hythread_library_t lib, hythread_group_t group) {
-    hythread_t thread;
-
-    if (lib == NULL) {
-        lib = TM_LIBRARY;
-    }
+ * @param[in] new_thread thread to register
+ * @param[in] lib        thread library to attach to
+ * @param[in] group      thread group, or NULL; in case of NULL this thread will
+ *                       go to the default group
+ */
+IDATA hythread_attach_to_group(hythread_t new_thread,
+                               hythread_library_t lib,
+                               hythread_group_t group)
+{
+    hythread_t self;
 
-    // Do nothing and return if the thread is already attached
-    thread = tm_self_tls;
-    if (thread) {
-        if (handle) {
-            *handle = thread;
-        }
+    assert(new_thread);
+    self = hythread_self();
+    if (self) {
+        // The thread is already attached, just fill a given thread structure.
+        *new_thread = *self;
         return TM_ERROR_NONE;
     }
-    if (handle) {
-        hythread_struct_init(handle);
-        thread = *handle;
-    } else {
-        thread = allocate_thread();
-    }
-    if (thread == NULL) {
-        return TM_ERROR_OUT_OF_MEMORY;
-    }
-    thread->library = lib;
-    thread->os_handle = os_thread_current();
-    assert(thread->os_handle);
 
-    TRACE(("TM: native attached: native: %p ",  tm_self_tls));
-    
-    return register_to_group(thread, group == NULL ? TM_DEFAULT_GROUP : group);
+    hythread_struct_init(new_thread);
+    assert(lib == NULL);
+    new_thread->library = TM_LIBRARY;
+    new_thread->os_handle = os_thread_current();
+    assert(new_thread->os_handle);
+
+    TRACE(("TM: native attached: native: %p ", self));
+
+    return register_to_group(new_thread,
+        (group == NULL ? TM_DEFAULT_GROUP : group));
 }
 
 /**
@@ -226,7 +221,12 @@
  * @see hythread_detach
  */
 IDATA VMCALL hythread_attach(hythread_t *handle) {
-    return hythread_attach_to_group(handle, TM_LIBRARY, NULL);
+    hythread_t thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    assert(thread);
+    if (handle) {
+        *handle = thread;
+    }
+    return hythread_attach_to_group(thread, NULL, NULL);
 }
 
 /**
@@ -240,7 +240,8 @@
  * @see hythread_detach
  */
 IDATA VMCALL hythread_attach_ex(hythread_t *handle, hythread_library_t lib) {
-    return hythread_attach_to_group(handle, lib, NULL);
+    assert(handle);
+    return hythread_attach_to_group(*handle, NULL, NULL);
 }
 
 /**
@@ -256,8 +257,6 @@
  * @param[in] thread a hythread_t representing the thread to be detached.
  * If this is NULL, the current thread is detached.
  * @return none
- * 
- * @see hythread_attach
  */
 void VMCALL hythread_detach(hythread_t thread) {
     IDATA status;
@@ -272,9 +271,12 @@
 
     // No actions required in case the specified thread is detached already.
     if (thread->group != NULL) {
-        assert(thread == tm_self_tls);
-        
-        thread_set_self(NULL);
+        // The thread can be detached from the other thread in case
+        // of forceful termination by hythread_cancel(), but thread
+        // local storage can be zeroed only for current thread.
+        if (thread == hythread_self() ) {
+            thread_set_self(NULL);
+        }
         fast_thread_array[thread->thread_id] = NULL;
         
         thread->prev->next = thread->next;
@@ -330,27 +332,15 @@
     //apr_thread_yield returns void 
     apr_thread_yield();
 }
+
 /** 
  * Return the hythread_t for the current thread.
  * 
  * @note Must be called only by an attached thread
  * 
  * @return hythread_t for the current thread
- *
- * @see hythread_attach
- * 
  */
 #ifdef APR_TLS_USE
-/**
- * Return the hythread_t for the current thread.
- *
- * @note Must be called only by an attached thread
- *
- * @return hythread_t for the current thread
- *
- * @see hythread_attach
- *
- */
 hythread_t hythread_self_slow() {
     hythread_t  thread;
     apr_status_t UNUSED apr_status;
@@ -367,22 +357,12 @@
 }
 #else 
 #if defined(_WIN32) && defined(HYTHREAD_FAST_TLS)
-/**
- * Return the hythread_t for the current thread.
- *
- * @note Must be called only by an attached thread
- *
- * @return hythread_t for the current thread
- *
- * @see hythread_attach
- *
- */
+
 hythread_t hythread_self_slow() {
     return hythread_self();
 }
 
-static void thread_set_self(hythread_t  thread) {
-  // tm_self_tls = thread;
+static void thread_set_self(hythread_t thread) {
 #ifndef _WIN64
 #   if (_MSC_VER >= 1400)
         __writefsdword(offsetof(NT_TIB, ArbitraryUserPointer), thread);
@@ -396,17 +376,9 @@
     __writegsqword(offsetof(NT_TIB, ArbitraryUserPointer), thread);
 #endif
 }
-#else
-/**
- * Return the hythread_t for the current thread.
- *
- * @note Must be called only by an attached thread
- *
- * @return hythread_t for the current thread
- *
- * @see hythread_attach
- *
- */
+
+#else // defined(_WIN32) && defined(HYTHREAD_FAST_TLS)
+
 hythread_t hythread_self_slow() {
     return hythread_self();
 }
@@ -414,8 +386,8 @@
 static void thread_set_self(hythread_t  thread) {
     tm_self_tls = thread;
 }
-#endif
-#endif
+#endif // defined(_WIN32) && defined(HYTHREAD_FAST_TLS)
+#endif // defined APR_TLS_USE
 
 IDATA thread_sleep_impl(I_64 millis, IDATA nanos, IDATA interruptable) {
     IDATA status;
@@ -514,6 +486,7 @@
  * @return none
  */
 void VMCALL hythread_cancel(hythread_t thread) {
+    hythread_detach(thread);
     os_thread_cancel(thread->os_handle);
 }
 
@@ -540,23 +513,11 @@
             //make any sense to exit on error, but continue terminating threads
         }       
     }
+    hythread_iterator_release(&iter);
 
     return TM_ERROR_NONE;
 }
 
-/**
- * Allocates and initializes a new thread_t structure.
- *
- */
-IDATA VMCALL hythread_struct_init(hythread_t *ret_thread) {
-    assert(ret_thread);
-    if (*ret_thread) {
-        reset_thread(*ret_thread);
-        return TM_ERROR_NONE;
-    }
-    (*ret_thread) = allocate_thread();
-    return (*ret_thread) == NULL ? TM_ERROR_OUT_OF_MEMORY : TM_ERROR_NONE;
-}
 //==============================================================================
 // Private functions
 
@@ -615,65 +576,46 @@
     return hythread_global_unlock(NULL);    
 }
 
-/*
- * Allocates and initializes a new thread_t structure 
- *
- * @return created and initialized thread_t structure
+/**
+ * Initializes a new thread structure.
  */
-static hythread_t allocate_thread() {
-    hythread_t ptr;
+IDATA VMCALL hythread_struct_init(hythread_t new_thread) 
+{
     IDATA status;
 
-    ptr = (hythread_t )calloc(1, sizeof(HyThread));
-    if (ptr == NULL) return NULL;
+    assert(new_thread);
+    if (!new_thread->stacksize) {
+        // Create thread primitives
+        status = hylatch_create(&new_thread->join_event, 1);
+        assert(status == TM_ERROR_NONE);
+        status = hysem_create(&new_thread->resume_event, 0, 1);
+        assert(status == TM_ERROR_NONE);
+        status = hymutex_create(&new_thread->mutex, TM_MUTEX_NESTED);
+        assert(status == TM_ERROR_NONE);
+        status = hycond_create(&new_thread->condition);
+        assert(status == TM_ERROR_NONE);
+        new_thread->stacksize = os_get_foreign_thread_stack_size();
+    }
+
+    new_thread->os_handle  = (osthread_t)NULL;
+    new_thread->priority   = HYTHREAD_PRIORITY_NORMAL;
+
+    // Suspension reset
+    new_thread->request = 0;
+    new_thread->suspend_count = 0;
+    new_thread->disable_count = 0;
+    new_thread->safepoint_callback = NULL;
+
+    hymutex_lock(&new_thread->mutex);
+    new_thread->state = TM_THREAD_STATE_ALLOCATED;
+    hymutex_unlock(&new_thread->mutex);
 
-    ptr->os_handle  = (osthread_t)NULL;
-    ptr->priority   = HYTHREAD_PRIORITY_NORMAL;
-    ptr->stacksize  = os_get_foreign_thread_stack_size();
-    
-    // Suspension
-    ptr->request = 0;
-    ptr->suspend_count = 0;
-    ptr->disable_count = 0;
-    status = hylatch_create(&ptr->join_event, 1);
-    assert(status == TM_ERROR_NONE);
-    status = hysem_create(&ptr->resume_event, 0, 1);
-    assert(status == TM_ERROR_NONE);
-    status = hymutex_create(&ptr->mutex, TM_MUTEX_NESTED);
+    status = hylatch_set(new_thread->join_event, 1);
     assert(status == TM_ERROR_NONE);
-    status = hycond_create(&ptr->condition);
+    status = hysem_set(new_thread->resume_event, 0);
     assert(status == TM_ERROR_NONE);
-    
-    ptr->state = TM_THREAD_STATE_ALLOCATED;
-    return ptr;
-}
-
-static void reset_thread(hythread_t thread) {
-    IDATA UNREF status;
-    if (thread->os_handle) {
-        int UNREF res = os_thread_join(thread->os_handle);
-        assert(!res);
-    }
-
-    hymutex_lock(&thread->mutex);
 
-    thread->os_handle  = (osthread_t)NULL;
-    thread->priority   = HYTHREAD_PRIORITY_NORMAL;
-
-    // Suspension
-    thread->request = 0;
-    thread->suspend_count = 0;
-    thread->disable_count = 0;
-    thread->safepoint_callback = NULL;
-    thread->state = TM_THREAD_STATE_ALLOCATED;
-
-    hymutex_unlock(&thread->mutex);
-
-    status = hylatch_set(thread->join_event, 1);
-    assert(status == TM_ERROR_NONE);
-    status = hysem_set(thread->resume_event, 0);
-    assert(status == TM_ERROR_NONE);
-    
+    return TM_ERROR_NONE;
 }
 
 // Wrapper around user thread start proc. Used to perform some duty jobs 
@@ -726,13 +668,13 @@
 }
 
 extern HY_CFUNC void VMCALL 
-    hythread_exit (hythread_monitor_t monitor) {
+hythread_exit (hythread_monitor_t monitor) {
    
     if (monitor !=NULL && monitor->owner == hythread_self()) {
         monitor->recursion_count = 0;
         hythread_monitor_exit(monitor);
     }
-
+    hythread_detach(NULL);
     os_thread_exit(0);
     // unreachable statement
     abort();
@@ -891,3 +833,9 @@
     status = hymutex_unlock(&lib->TM_LOCK);
     return status;
 } // hythread_countdown_nondaemon_threads
+
+IDATA VMCALL hythread_get_struct_size()
+{
+    return (IDATA)sizeof(HyThread);
+} // hythread_get_struct_size
+

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c Fri Aug 17 10:46:01 2007
@@ -51,14 +51,16 @@
         return TM_ERROR_OUT_OF_MEMORY;
     }
     r = hymutex_create(&mon->mutex, TM_MUTEX_NESTED);
-    if (r) goto cleanup;
+    if (r) {
+        goto cleanup;
+    }
     r = hycond_create(&mon->condition);
-    if (r) goto cleanup;
+    if (r) {
+        goto cleanup;
+    }
 
     mon->flags = flags;
     mon->name  = name;
-    mon->owner = 0;
-    mon->notify_flag = 0;
 
     *mon_ptr = mon;
     return TM_ERROR_NONE;
@@ -165,10 +167,6 @@
         return TM_ERROR_ILLEGAL_STATE;
     }
 
-#ifdef _DEBUG
-    mon_ptr->last_wait=tm_self_tls;
-#endif
-
     saved_recursion = mon_ptr->recursion_count;
 
     assert(saved_recursion>=0);
@@ -184,12 +182,15 @@
 
     do {
         apr_time_t start;
-        assert(0 <= mon_ptr->notify_flag && mon_ptr->notify_flag < mon_ptr->wait_count);
+        assert(mon_ptr->notify_count >= 0);
+        assert(mon_ptr->notify_count < mon_ptr->wait_count);
         start = apr_time_now();
         status = condvar_wait_impl(&mon_ptr->condition, &mon_ptr->mutex, ms, nano, interruptable);
         if (status != TM_ERROR_NONE
-	                    || mon_ptr->notify_flag || hythread_interrupted(self))
+            || mon_ptr->notify_count || hythread_interrupted(self))
+        {
             break;
+        }
         // we should not change ms and nano if both are 0 (meaning "no timeout")
         if (ms || nano) {
             apr_interval_time_t elapsed;
@@ -209,14 +210,23 @@
             assert(0 <= nano && nano < 1000000);
         }
     } while (1);
-    if (mon_ptr->notify_flag)
-        mon_ptr->notify_flag -= 1;
+
+    // consume the notify_count unless we got an error
+    // or were interrupted
+    if (mon_ptr->notify_count > 0
+        && ((status == TM_ERROR_NONE && !hythread_interrupted(self))
+            || mon_ptr->notify_count == mon_ptr->wait_count))
+    {
+        mon_ptr->notify_count--;
+    }
+
     hymutex_lock(&self->mutex);
     self->state &= ~TM_THREAD_STATE_IN_MONITOR_WAIT;
     self->current_condition = NULL;
     self->waited_monitor = NULL;
     hymutex_unlock(&self->mutex);
     mon_ptr->wait_count--;
+    assert(mon_ptr->notify_count <= mon_ptr->wait_count);
 
     if (self->request) {
         int save_count;
@@ -326,7 +336,7 @@
     if (mon_ptr->owner != tm_self_tls) {
         return TM_ERROR_ILLEGAL_STATE;
     }
-    mon_ptr->notify_flag = mon_ptr->wait_count;
+    mon_ptr->notify_count = mon_ptr->wait_count;
     return hycond_notify_all(&mon_ptr->condition);
 }
 
@@ -372,8 +382,8 @@
     if (mon_ptr->owner != tm_self_tls) {
         return TM_ERROR_ILLEGAL_STATE;
     }
-    if (mon_ptr->notify_flag < mon_ptr->wait_count)
-        mon_ptr->notify_flag += 1;
+    if (mon_ptr->notify_count < mon_ptr->wait_count)
+        mon_ptr->notify_count += 1;
     return hycond_notify(&mon_ptr->condition);
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c Fri Aug 17 10:46:01 2007
@@ -37,7 +37,6 @@
  */
 void VMCALL hythread_interrupt(hythread_t thread) {
     IDATA status;
-    hythread_t thr = NULL;
     hymutex_lock(&thread->mutex);
     thread->state |= TM_THREAD_STATE_INTERRUPTED;
     
@@ -49,19 +48,20 @@
     // If thread was doing any kind of wait, notify it.
     if (thread->state & (TM_THREAD_STATE_PARKED | TM_THREAD_STATE_SLEEPING)) {
         if (thread->current_condition) {
-	    status = hycond_notify_all(thread->current_condition);
-	    assert(status == TM_ERROR_NONE);
-	}
+            status = hycond_notify_all(thread->current_condition);
+            assert(status == TM_ERROR_NONE);
+        }
     } else if (thread->state & TM_THREAD_STATE_IN_MONITOR_WAIT) {
         if (thread->current_condition && (hythread_monitor_try_enter(thread->waited_monitor) == TM_ERROR_NONE)) {
             hythread_monitor_interrupt_wait(thread->waited_monitor, thread);
             hythread_monitor_exit(thread->waited_monitor);
         } else {
-            status = hythread_create(&thr, 0, 0, 0, interrupter_thread_function, (void *)thread);
+            hythread_t interrupt_thread = (hythread_t)calloc(1, hythread_get_struct_size());
+            status = hythread_create_with_group(interrupt_thread, 0, 0, 0,
+                interrupter_thread_function, (void *)thread);
             assert (status == TM_ERROR_NONE);
-	}
+        }
     }
-
     hymutex_unlock(&thread->mutex);
 }
 
@@ -81,7 +81,7 @@
     hymutex_unlock(&thread->mutex);
 
     hythread_monitor_enter(monitor);
-    hythread_monitor_notify_all(monitor);
+    hythread_monitor_interrupt_wait(monitor, thread);
 
     hythread_exit(monitor);
     return 0;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c Fri Aug 17 10:46:01 2007
@@ -28,7 +28,8 @@
 
 
 /**
- * Creates the iterator that can be used to retrieve all threads in the specific group.
+ * Creates the iterator that can be used to retrieve all threads in the specific group
+ * and acquires the thread lock.
  * 
  * @param[in] group thread group number
  */
@@ -42,7 +43,8 @@
 }
 
 /**
- * Releases the iterator over the specific thread group.
+ * Releases the iterator over the specific thread group and releases the thread
+ * lock.
  * 
  * @param[in] it thread group iterator
  */

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c Fri Aug 17 10:46:01 2007
@@ -125,7 +125,6 @@
 int inflate_contended=0;
 int inflate_waited=0;
 int unreserve_count_self=0;
-int inflate_count=0;
 int fat_lock2_count = 0;
 int init_reserve_cout = 0;
 int cas_cout = 0;
@@ -622,7 +621,6 @@
     // however this invariant is true because we hold monitor->mutex during this function
     // so it cannot be called twice for the signle monitor concurrently
 
-    TRACE(("inflate tmj%d\n", ++inflate_count));
     lockword = *lockword_ptr;
     if (IS_FAT_LOCK (lockword)) {
         return locktable_get_fat_monitor(FAT_LOCK_ID(lockword));
@@ -657,8 +655,6 @@
     TRACE(("hythread_inflate_lock  %d thread: %d\n", FAT_LOCK_ID(*lockword_ptr), tm_self_tls->thread_id));
     //assert(FAT_LOCK_ID(*lockword_ptr) != 2);
     TRACE(("FAT ID : 0x%x", *lockword_ptr));
-    fat_monitor->inflate_count++;
-    fat_monitor->inflate_owner=tm_self_tls;
 #ifdef LOCK_RESERVATION
     assert(!IS_RESERVED(*lockword_ptr));
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h Fri Aug 17 10:46:01 2007
@@ -214,7 +214,6 @@
      * Handle to OS thread.
      */
     osthread_t os_handle;
-    
 
 // Synchronization stuff
 
@@ -328,30 +327,27 @@
  */
 typedef struct HyThreadMonitor {
     
-    /**
-     * Mutex
-     */
+    /// Monitor mutex.
     hymutex_t mutex;
 
-    /**
-     * Condition variable
-     */
+    /// Monitor condition varibale.
     hycond_t condition;
     
-    /**
-     * Recursion count 
-     */
+    /// Mutex recurtion count.
     IDATA recursion_count;
-    hythread_t owner; 
-    hythread_t inflate_owner;
-    hythread_t last_wait;
-    int inflate_count;
+
+    /// Current mutex owner.
+    hythread_t owner;
+
+    /// Number of threads waiting on a condition variable
+    /// or queued to acquire a monitor mutex after wakeup
     int wait_count;
-    int notify_flag;
 
-    /**
-     * Owner thread ID. 
-     */
+    /// Number of notify events sent by the user,
+    /// it is bounded by the wait_count
+    int notify_count;
+
+    /// Owner thread ID. 
     IDATA thread_id;
 
     UDATA flags;
@@ -510,7 +506,6 @@
 int os_thread_set_priority(osthread_t thread, int priority);
 osthread_t os_thread_current();
 int os_thread_cancel(osthread_t);
-int os_thread_join(osthread_t);
 void os_thread_exit(IDATA status);
 void os_thread_yield_other(osthread_t);
 int os_get_thread_times(osthread_t os_thread, int64* pkernel, int64* puser);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp Fri Aug 17 10:46:01 2007
@@ -109,8 +109,9 @@
         void **args = (void **)STD_MALLOC(sizeof(void *) * 2);
         args[0] = (void*)java_vm;
         args[1] = (void*)get_system_thread_group(jni_env);
-        fin_thread_info->thread_ids[i] = NULL;
-        status = hythread_create(&fin_thread_info->thread_ids[i], 0, FINALIZER_THREAD_PRIORITY, 0, (hythread_entrypoint_t)finalizer_thread_func, args);
+        fin_thread_info->thread_ids[i] = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+        status = hythread_create_with_group(fin_thread_info->thread_ids[i], NULL, 0,
+            FINALIZER_THREAD_PRIORITY, (hythread_entrypoint_t)finalizer_thread_func, args);
         assert(status == TM_ERROR_NONE);
         hysem_wait(fin_thread_info->attached_sem);
     }    

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp Fri Aug 17 10:46:01 2007
@@ -65,7 +65,9 @@
     void **args = (void **)STD_MALLOC(sizeof(void *)*2);
     args[0] = (void *)java_vm;
     args[1] = (void*)get_system_thread_group(jni_env);
-    status = hythread_create(NULL, 0, REF_ENQUEUE_THREAD_PRIORITY, 0, (hythread_entrypoint_t)ref_enqueue_thread_func, args);
+    hythread_t thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+    status = hythread_create_with_group(thread, NULL, 0, REF_ENQUEUE_THREAD_PRIORITY,
+        (hythread_entrypoint_t)ref_enqueue_thread_func, args);
     assert(status == TM_ERROR_NONE);
     
     hysem_wait(ref_thread_info->attached_sem);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Fri Aug 17 10:46:01 2007
@@ -598,14 +598,17 @@
 
     native_thread = hythread_self();
     if (!native_thread) {
-        status = (jint)hythread_attach_to_group(&native_thread,
-            ((JavaVM_Internal *)java_vm)->vm_env->hythread_lib, NULL);
-        if (status != TM_ERROR_NONE) return JNI_ERR;
+        hythread_t native_thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+        assert(native_thread);
+        IDATA hy_status = hythread_attach_to_group(native_thread, NULL, NULL);
+        if (hy_status != TM_ERROR_NONE)
+            return JNI_ERR;
     }
     assert(native_thread);
 
     status = vm_attach(java_vm, &jni_env);
-    if (status != JNI_OK) return status;
+    if (status != JNI_OK)
+        return status;
 
     *p_jni_env = jni_env;
 
@@ -630,7 +633,9 @@
 
     vm_env = java_vm->vm_env;
 
-    if (hythread_attach_ex(NULL, vm_env->hythread_lib) != TM_ERROR_NONE) {
+    hythread_t main_thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+    assert(main_thread);
+    if (hythread_attach_to_group(main_thread, NULL, NULL) != TM_ERROR_NONE) {
         return JNI_ERR;
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Fri Aug 17 10:46:01 2007
@@ -309,28 +309,36 @@
 
     status = JNI_GetCreatedJavaVMs(NULL, 0, &nVMs);
     assert(nVMs <= 1);
-    if (status != JNI_OK) return;
+    if (status != JNI_OK)
+        return;
 
     vmBuf = (JavaVM **) STD_MALLOC(nVMs * sizeof(JavaVM *));
     status = JNI_GetCreatedJavaVMs(vmBuf, nVMs, &nVMs);
     assert(nVMs <= 1);
-    if (status != JNI_OK) goto cleanup;
-
-    status = hythread_attach(NULL);
-    if (status != TM_ERROR_NONE) goto cleanup;
-
+    if (status != JNI_OK)
+        goto cleanup;
 
     threadBuf = (hythread_t *) STD_MALLOC((nVMs + 1) * sizeof(hythread_t));
-    threadBuf[nVMs] = NULL;
+    assert(threadBuf);
 
     // Create a new thread for each VM to avoid scalability and deadlock problems.
     for (int i = 0; i < nVMs; i++) {
-        threadBuf[i] = NULL;
-        hythread_create((threadBuf + i), 0, HYTHREAD_PRIORITY_NORMAL, 0, vm_interrupt_entry_point, (void *)vmBuf[i]);
+        threadBuf[i] = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+        assert(threadBuf[i]);
+        status = hythread_create_with_group(threadBuf[i], NULL, 0,
+            HYTHREAD_PRIORITY_NORMAL, vm_interrupt_entry_point, (void *)vmBuf[i]);
+        assert(status == TM_ERROR_NONE);
     }
 
     // spawn a new thread which will terminate the process.
-    hythread_create(NULL, 0, HYTHREAD_PRIORITY_NORMAL, 0, vm_interrupt_process, (void *)threadBuf);
+    threadBuf[nVMs] = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+    assert(threadBuf[nVMs]);
+    status = hythread_create_with_group(threadBuf[nVMs], NULL, 0,
+        HYTHREAD_PRIORITY_NORMAL, vm_interrupt_process, (void *)threadBuf);
+    assert(status == TM_ERROR_NONE);
+
+    // set a NULL terminator
+    threadBuf[nVMs] = NULL;
 
 cleanup:
     STD_FREE(vmBuf);
@@ -347,21 +355,22 @@
 
     status = JNI_GetCreatedJavaVMs(NULL, 0, &nVMs);
     assert(nVMs <= 1);
-    if (status != JNI_OK) return;
+    if (status != JNI_OK)
+        return;
 
     vmBuf = (JavaVM **) STD_MALLOC(nVMs * sizeof(JavaVM *));
     status = JNI_GetCreatedJavaVMs(vmBuf, nVMs, &nVMs);
     assert(nVMs <= 1);
-
-    IDATA htstatus;
-    if (status != JNI_OK) goto cleanup;
-
-    htstatus = hythread_attach(NULL);
-    if (htstatus != TM_ERROR_NONE) goto cleanup;
+    if (status != JNI_OK)
+        goto cleanup;
 
     // Create a new thread for each VM to avoid scalability and deadlock problems.
     for (int i = 0; i < nVMs; i++) {
-        hythread_create(NULL, 0, HYTHREAD_PRIORITY_NORMAL, 0, vm_dump_entry_point, (void *)vmBuf[i]);
+        hythread_t thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+        assert(thread);
+        IDATA hy_status = hythread_create_with_group(thread, NULL, 0,
+            HYTHREAD_PRIORITY_NORMAL, vm_dump_entry_point, (void *)vmBuf[i]);
+        assert(hy_status == TM_ERROR_NONE);
     }
 
 cleanup:

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Fri Aug 17 10:46:01 2007
@@ -2313,7 +2313,9 @@
 
     // create TI event thread
     JNIEnv *jni_env = p_TLS_vmthread->jni_env;
-    IDATA status = hythread_create(&ti->event_thread, 0, 0, 0,
+    ti->event_thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+    assert(ti->event_thread);
+    IDATA status = hythread_create_with_group(ti->event_thread, NULL, 0, 0,
         jvmti_event_thread_function, jni_env);
     if( status != TM_ERROR_NONE ) {
         DIE("jvmti_create_event_thread: creating thread is failed!");

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp Fri Aug 17 10:46:01 2007
@@ -124,16 +124,7 @@
         return TM_ERROR_NULL_POINTER;
     }
     hythread_t native_thread = vm_jthread_get_tm_data(java_thread);
-
-    // This is for irregular use. In ordinary live valid jthread instance
-    // contains weak reference associated with it and native thread to reuse. 
-    if (native_thread == NULL) {
-        assert(0);
-        if (!jthread_thread_init(jni_env, java_thread, NULL, 0)) {
-            return TM_ERROR_OUT_OF_MEMORY;
-        }
-        native_thread = vm_jthread_get_tm_data(java_thread);
-    }
+    assert(native_thread);
 
     vm_thread_t vm_thread =
         (vm_thread_t) hythread_tls_get(native_thread, TM_THREAD_VM_TLS_KEY);
@@ -164,9 +155,8 @@
         attrs->stacksize = default_stacksize;
     }
 
-    status =
-        hythread_create(&native_thread, attrs->stacksize,
-                        attrs->priority, 0, jthread_wrapper_proc, attrs);
+    status = hythread_create_with_group(native_thread, NULL, attrs->stacksize,
+                        attrs->priority, jthread_wrapper_proc, attrs);
 
     TRACE(("TM: Created thread: id=%d", hythread_get_id(native_thread)));
 
@@ -242,9 +232,12 @@
             // delete used weak reference
             env->DeleteGlobalRef(vm_thread->weak_ref);
         }
+    } else {
+        native_thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());
+        assert(native_thread);
     }
     
-    IDATA status = hythread_struct_init(&native_thread);
+    IDATA status = hythread_struct_init(native_thread);
     if (status != TM_ERROR_NONE) {
         return 0;
     }
@@ -403,11 +396,31 @@
  */
 static void stop_callback(void)
 {
-    vm_thread_t vm_thread = p_TLS_vmthread;
+    hythread_t native_thread = hythread_self();
+    assert(native_thread);
+    vm_thread_t vm_thread =
+        (vm_thread_t) hythread_tls_get(native_thread, TM_THREAD_VM_TLS_KEY);
     assert(vm_thread);
     jobject excn = vm_thread->stop_exception;
 
+    // Does not return if the exception could be thrown straight away
     jthread_throw_exception_object(excn);
+
+    // getting here means top stack frame is non-unwindable.
+    if (hythread_get_state(native_thread) &
+            (TM_THREAD_STATE_SLEEPING | TM_THREAD_STATE_WAITING_WITH_TIMEOUT
+                | TM_THREAD_STATE_WAITING | TM_THREAD_STATE_IN_MONITOR_WAIT
+                | TM_THREAD_STATE_WAITING_INDEFINITELY | TM_THREAD_STATE_PARKED))
+    {
+        // This is needed for correct stopping of a thread blocked on monitor_wait.
+        // The thread needs some flag to exit its waiting loop.
+        // We piggy-back on interrupted status. A correct exception from TLS
+        // will be thrown because the check of exception status on leaving
+        // JNI frame comes before checking return status in Object.wait().
+        // Interrupted status will be cleared by function returning TM_ERROR_INTERRUPT.
+        // (though, in case of parked thread, it will not be cleared)
+        hythread_interrupt(native_thread);
+    }
 } // stop_callback
 
 /**

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp?view=diff&rev=567096&r1=567095&r2=567096
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp Fri Aug 17 10:46:01 2007
@@ -117,11 +117,10 @@
 #endif // _DEBUG
 
     // allocate VM thread
-    vm_thread = (vm_thread_t)STD_MALLOC(sizeof(VM_thread));
+    vm_thread = (vm_thread_t)STD_CALLOC(1, sizeof(VM_thread));
     if (!vm_thread) {
         return NULL;
     }
-    memset(vm_thread, 0, sizeof(VM_thread));
 
     // set VM thread to thread local storage
     IDATA status =



Mime
View raw message