harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r434076 [10/18] - in /incubator/harmony/enhanced/drlvm/trunk: build/make/components/ build/make/components/vm/ build/make/targets/ build/patches/lnx/ build/patches/lnx/APR/ build/patches/lnx/APR/threadproc/ build/patches/lnx/APR/threadproc/...
Date Wed, 23 Aug 2006 16:49:21 GMT
Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,379 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.13 $
+ */  
+
+/**
+ * @file thread_native_fat_monitor.c
+ * @brief Hythread fat monitors related functions
+ */
+
+/** @name Fat monitors support. Implement thin-fat scheme.
+ */
+//@{
+
+#undef LOG_DOMAIN
+#define LOG_DOMAIN "tm.locks"
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+/**
+ * Acquire and initialize a new monitor from the threading library.
+ *
+ * @param[out] mon_ptr pointer to a hythread_monitor_t to be set to point to the new monitor
+ * @param[in] flags initial flag values for the monitor
+ * @param[in] name pointer to a C string with a description of how the monitor will be used (may be NULL)<br>
+ * If non-NULL, the C string must be valid for the entire life of the monitor
+ *
+ * @return  0 on success or negative value on failure
+ *
+ * @see hythread_monitor_destroy
+ *
+ */
+IDATA VMCALL hythread_monitor_init_with_name(hythread_monitor_t *mon_ptr, UDATA flags, char *name) {
+    hythread_monitor_t mon;
+    apr_pool_t *pool = get_local_pool(); 
+    apr_status_t apr_status;
+        IDATA status;
+        
+        mon = apr_pcalloc(pool, sizeof(HyThreadMonitor));
+        if(mon == NULL) {
+                return TM_ERROR_OUT_OF_MEMORY;
+        }
+    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(mon->mutex), TM_MUTEX_NESTED, pool);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+        
+    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(mon->condition), pool);
+
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+
+        mon->pool  = pool;
+    mon->flags = flags;
+    mon->name  = name;
+    mon->owner = 0;
+
+    status=hythread_monitor_enter(mon);
+        if (status != TM_ERROR_NONE) return status;
+
+        *mon_ptr = mon;
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Enter a monitor.
+ *
+ * A thread may re-enter a monitor it owns multiple times, but must
+ * exit the monitor the same number of times before any other thread
+ * wanting to enter the monitor is permitted to continue.
+ *
+ * @param[in] mon_ptr a monitor to be entered
+ * @return 0 on success<br>
+ * HYTHREAD_PRIORITY_INTERRUPTED if the thread was priority interrupted while blocked
+ *
+ * @see hythread_monitor_enter_using_threadId, hythread_monitor_exit, hythread_monitor_exit_using_threadId
+ */
+IDATA VMCALL hythread_monitor_enter(hythread_monitor_t mon_ptr) {
+    IDATA status;
+    hythread_t  self = tm_self_tls;
+    if (mon_ptr->owner != self) {
+        status = hymutex_lock(mon_ptr->mutex);
+        mon_ptr->owner = self;
+        assert(status == TM_ERROR_NONE);
+     } else {
+        assert(mon_ptr->recursion_count >=0);
+            mon_ptr->recursion_count++;
+        status = TM_ERROR_NONE;
+     }
+     return status;
+}
+
+
+/**
+ * Attempt to enter a monitor without blocking.
+ *
+ * If the thread must block before it enters the monitor this function
+ * returns immediately with a negative value to indicate failure.
+ *
+ * @param[in] mon_ptr a monitor
+ * @return  0 on success or negative value on failure
+ *
+ * @see hythread_monitor_try_enter_using_threadId
+ *
+ */
+IDATA VMCALL hythread_monitor_try_enter(hythread_monitor_t mon_ptr) {  
+    IDATA status;
+    hythread_t self = tm_self_tls;
+    if (mon_ptr->owner != self) {
+            status = hymutex_trylock(mon_ptr->mutex);
+        if(status == TM_ERROR_NONE) {
+             mon_ptr->owner = tm_self_tls;
+        }
+            return status;
+    } else {
+         assert(mon_ptr->recursion_count >=0);
+         mon_ptr->recursion_count++;
+         return TM_ERROR_NONE;
+    }
+}
+
+/**
+ * Exit a monitor.
+ *
+ * Exit a monitor, and if the owning count is zero, release it.
+ *
+ * @param[in] mon_ptr a monitor to be exited
+ * @return 0 on success, <br>HYTHREAD_ILLEGAL_MONITOR_STATE if the current thread does not own the monitor
+ *
+ * @see hythread_monitor_exit_using_threadId, hythread_monitor_enter, hythread_monitor_enter_using_threadId
+ */
+IDATA VMCALL hythread_monitor_exit(hythread_monitor_t mon_ptr) {
+    IDATA status = TM_ERROR_NONE;
+    assert(mon_ptr->recursion_count >= 0);
+    
+    if(mon_ptr->owner != tm_self_tls) {
+        TRACE(("exit TM_ERROR_ILLEGAL_STATE  owner: %d self: %d, rec: %d\n", mon_ptr->owner?mon_ptr->owner->thread_id:0, tm_self_tls->thread_id, mon_ptr->recursion_count));
+        return TM_ERROR_ILLEGAL_STATE;
+    }
+    if(mon_ptr->recursion_count == 0) {
+        mon_ptr->owner = NULL;
+        status = hymutex_unlock(mon_ptr->mutex);
+    } else {
+        mon_ptr->recursion_count--;
+    }
+    assert(status == TM_ERROR_NONE);
+    return status;
+}
+
+
+//Use this define to workaround poor condition variables implmentation.
+//If defined, local wait scheme implementation will be used;
+//#define NO_COND_VARS
+IDATA monitor_wait_impl(hythread_monitor_t mon_ptr, I_64 ms, IDATA nano, IDATA interruptable) {
+        IDATA status;
+        int saved_recursion;
+        //int saved_disable_count;
+        hythread_t self = tm_self_tls;
+    if(mon_ptr->owner != self ) {
+        return TM_ERROR_ILLEGAL_STATE;
+    }
+
+#ifdef _DEBUG
+        mon_ptr->last_wait=tm_self_tls;
+#endif
+    
+    mon_ptr->wait_count++;
+        saved_recursion = mon_ptr->recursion_count;
+        
+    assert(saved_recursion<1);
+    
+    mon_ptr->owner = NULL;
+        mon_ptr->recursion_count =0;
+#ifdef NO_COND_VARS
+    assert(mon_ptr->owner != self);
+    status=hythread_monitor_exit(mon_ptr);
+        if (status != TM_ERROR_NONE) return status;
+    saved_disable_count = reset_suspend_disable();
+    ms = ms*1000;     
+    while(--ms != 0 &&  mon_ptr->notify_flag!=1) {
+        hythread_yield();
+    }
+    if (ms == 0) {
+        status = TM_ERROR_TIMEOUT;
+    } else {
+        status = TM_ERROR_NONE;
+    }
+    status=hythread_monitor_enter(mon_ptr);
+        if (status != TM_ERROR_NONE) return status;
+    set_suspend_disable(saved_disable_count);
+
+#else 
+    //printf("starting wait: %x, %x \n", mon_ptr->condition, hythread_self());
+        status =  condvar_wait_impl(mon_ptr->condition, mon_ptr->mutex, ms, nano, interruptable);
+    //printf("finishing wait: %x, %x \n", mon_ptr->condition, hythread_self());
+#endif
+        mon_ptr->recursion_count = saved_recursion;
+        mon_ptr->owner = self;
+        assert(mon_ptr->owner);
+        return status;
+}
+
+/**
+ * Wait on a monitor until notified.
+ *
+ * Release the monitor, wait for a signal (notification), then re-acquire the monitor.
+ *
+ * @param[in] mon_ptr a monitor to be waited on
+ * @return 0 if the monitor has been waited on, notified, and reobtained<br>
+ * HYTHREAD_INVALID_ARGUMENT if millis or nanos is out of range (millis or nanos < 0, or nanos >= 1E6)<br>
+ * HYTHREAD_ILLEGAL_MONITOR_STATE if the current thread does not own the monitor
+ *
+ * @see hythread_monitor_wait_interruptable, hythread_monitor_wait_timed, hythread_monitor_enter
+ *
+ */
+IDATA VMCALL hythread_monitor_wait(hythread_monitor_t mon_ptr) {
+        return monitor_wait_impl(mon_ptr,0, 0, WAIT_NONINTERRUPTABLE); 
+}
+
+/**
+ * Wait on a monitor until notified or timed out.
+ *
+ * A timeout of 0 (0ms, 0ns) indicates wait indefinitely.
+ *
+ * @param[in] mon_ptr a monitor to be waited on
+ * @param[in] ms >=0
+ * @param[in] nano >=0
+ *
+ * @return  0 the monitor has been waited on, notified, and reobtained<br>
+ * HYTHREAD_INVALID_ARGUMENT millis or nanos is out of range (millis or nanos < 0, or nanos >= 1E6)<br>
+ * HYTHREAD_ILLEGAL_MONITOR_STATE the current thread does not own the monitor<br>
+ * HYTHREAD_TIMED_OUT the timeout expired
+ *
+ * @see hythread_monitor_wait, hythread_monitor_wait_interruptable, hythread_monitor_enter
+ *
+ */
+IDATA VMCALL hythread_monitor_wait_timed(hythread_monitor_t mon_ptr, I_64 ms, IDATA nano) {
+        return monitor_wait_impl(mon_ptr, ms, nano, WAIT_NONINTERRUPTABLE); 
+}
+
+/**
+ * Wait on a monitor until notified, interrupted (priority or normal), or timed out.
+ *
+ * A timeout of 0 (0ms, 0ns) indicates wait indefinitely.
+ *
+ *
+ * @param[in] mon_ptr a monitor to be waited on
+ * @param[in] ms >=0
+ * @param[in] nano >=0
+ *
+ * @return   0 the monitor has been waited on, notified, and reobtained<br>
+ * HYTHREAD_INVALID_ARGUMENT if millis or nanos is out of range (millis or nanos < 0, or nanos >= 1E6)<br>
+ * HYTHREAD_ILLEGAL_MONITOR_STATE if the current thread does not own the monitor<br>
+ * HYTHREAD_INTERRUPTED if the thread was interrupted while waiting<br>
+ * HYTHREAD_PRIORITY_INTERRUPTED if the thread was priority interrupted while waiting, or while re-obtaining the monitor<br>
+ * HYTHREAD_TIMED_OUT if the timeout expired<br>
+ *
+ * @see hythread_monitor_wait, hythread_monitor_wait_timed, hythread_monitor_enter
+ * @see hythread_interrupt, hythread_priority_interrupt *
+ */
+IDATA VMCALL hythread_monitor_wait_interruptable(hythread_monitor_t mon_ptr, I_64 ms, IDATA nano) {
+        return monitor_wait_impl(mon_ptr, ms, nano, WAIT_INTERRUPTABLE); 
+}
+
+/**
+ * Returns how many threads are currently waiting on a monitor.
+ *
+ * @note This can only be called by the owner of this monitor.
+ *
+ * @param[in] mon_ptr a monitor
+ * @return number of threads waiting on the monitor (>=0)
+ */
+UDATA VMCALL hythread_monitor_num_waiting(hythread_monitor_t mon_ptr) {
+    return mon_ptr->wait_count;
+}
+
+/**
+ * Notify all threads waiting on a monitor.
+ *
+ * A thread is considered to be waiting on the monitor if
+ * it is currently blocked while executing hythread_monitor_wait on the monitor.
+ *
+ * If no threads are waiting, no action is taken.
+ *
+ *
+ * @param[in] mon_ptr a monitor to be signaled
+ * @return  0 once the monitor has been signaled<br>HYTHREAD_ILLEGAL_MONITOR_STATE if the current thread does not own the monitor
+ *
+ * @see hythread_monitor_notify, hythread_monitor_enter, hythread_monitor_wait
+ */
+IDATA VMCALL hythread_monitor_notify_all(hythread_monitor_t mon_ptr) {      
+    if(mon_ptr->owner != tm_self_tls) {
+        return TM_ERROR_ILLEGAL_STATE;
+    }
+    mon_ptr->wait_count = 0;
+#ifdef NO_COND_VARS
+        mon_ptr->notify_flag=1;
+        return TM_ERROR_NONE;
+#else
+        return hycond_notify_all(mon_ptr->condition);   
+#endif
+}
+
+
+/**
+ * Notify a single thread waiting on a monitor.
+ *
+ * A thread is considered to be waiting on the monitor if
+ * it is currently blocked while executing hythread_monitor_wait on the monitor.
+ *
+ * If no threads are waiting, no action is taken.
+ *
+ * @param[in] mon_ptr a monitor to be signaled
+ * @return  0 once the monitor has been signaled<br>HYTHREAD_ILLEGAL_MONITOR_STATE if the current thread does not own the monitor
+ *
+ * @see hythread_monitor_notify_all, hythread_monitor_enter, hythread_monitor_wait
+ */
+IDATA VMCALL hythread_monitor_notify(hythread_monitor_t mon_ptr) {      
+    if(mon_ptr->owner != tm_self_tls) {
+        return TM_ERROR_ILLEGAL_STATE;
+    }
+    if (mon_ptr->wait_count > 0){
+        mon_ptr->wait_count--;
+    }
+#ifdef NO_COND_VARS
+        mon_ptr->notify_flag=1;
+        return TM_ERROR_NONE;
+#else
+        return hycond_notify(mon_ptr->condition);   
+#endif
+}
+
+
+/**
+ * Destroy a monitor.
+ *
+ * Destroying a monitor frees the internal resources associated
+ * with it.
+ *
+ * @note A monitor must NOT be destroyed if threads are waiting on
+ * it, or if it is currently owned.
+ *
+ * @param[in] monitor a monitor to be destroyed
+ * @return  0 on success or non-0 on failure (the monitor is in use)
+ *
+ * @see hythread_monitor_init_with_name
+ */
+IDATA VMCALL hythread_monitor_destroy(hythread_monitor_t monitor) {
+    apr_status_t apr_status;
+        apr_pool_t *pool = monitor->pool;
+    if (monitor->owner != NULL || monitor->wait_count > 0) {
+        return TM_ERROR_ILLEGAL_STATE;
+    }
+    
+    if(pool != get_local_pool()) {
+        return local_pool_cleanup_register(hythread_monitor_destroy, monitor);
+    }
+    apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)monitor->mutex);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)monitor->condition);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    // apr_pool_free(pool, monitor);
+    return TM_ERROR_NONE;       
+}
+
+//@}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_groups.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_groups.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_groups.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_groups.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,140 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Nikolay Kuznetsov
+ * @version $Revision: 1.1.2.5 $
+ */  
+
+/**
+ * @file thread_native_groups.c
+ * @brief Hythread group related functions
+ */
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+extern hythread_group_t group_list;  // list of thread groups
+extern int groups_count;        // number of thread groups
+
+   
+/** @name Thread groups support
+ */
+//@{
+
+/**
+ * Creates the thread group.
+ *
+ * @param[out] group thread group created
+ */
+IDATA VMCALL hythread_group_create(hythread_group_t *group) {
+    hythread_t dummy;
+    apr_pool_t  *group_pool;
+    apr_status_t apr_status;
+        IDATA status;
+    
+    apr_status = apr_pool_create(&(group_pool), TM_POOL);
+    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    
+    status=hythread_global_lock();
+        if (status != TM_ERROR_NONE) return status;
+    
+    (*group) = (hythread_group_t )apr_palloc(group_pool, sizeof(HyThreadGroup));
+    if (! *group){
+       hythread_global_unlock();
+       return TM_ERROR_OUT_OF_MEMORY;
+    }
+
+    (*group)->pool         = group_pool;
+    (*group)->next         = group_list;
+    (*group)->prev         = group_list->prev;
+
+    group_list->prev->next = (*group);
+    group_list->prev       = (*group);
+    
+    //dummy thread as the head of the group
+    ////
+    dummy = (hythread_t)apr_pcalloc(group_pool, sizeof(HyThread));
+    if (! dummy){
+        hythread_global_unlock();
+        return TM_ERROR_OUT_OF_MEMORY;
+    }
+    dummy->next = dummy->prev = dummy;
+    dummy->group = (*group);
+    dummy->thread_id = 0;
+    
+    (*group)->thread_list  = dummy;
+    (*group)->threads_count = 0;
+    
+    groups_count++;
+    status=hythread_global_unlock();
+
+    return status;
+}
+
+/**
+ * Releases the thread group.
+ *
+ * @param[out] group thread group created
+ */
+
+IDATA VMCALL hythread_group_release(hythread_group_t group) {
+        IDATA status;
+    if (group->threads_count > 0) return TM_ERROR_RUNNING_THREADS;
+    
+    status=hythread_global_lock();
+        if (status != TM_ERROR_NONE) return status;
+    groups_count--;
+    group->prev->next = group->next;
+    group->next->prev = group->prev;
+    
+    apr_pool_destroy(group->pool);
+    status=hythread_global_unlock();
+    
+    return status;
+}
+
+/**
+ * Returns all thread groups as array.
+ *
+ * @param[out] list thread group array
+ * @param[out] size array size
+ */
+IDATA VMCALL hythread_group_get_list(hythread_group_t **list, int* size) {
+    hythread_group_t cur;
+    int i=0;
+    hythread_group_t *array_for_list;
+    IDATA status;
+    status=hythread_global_lock();
+    if (status != TM_ERROR_NONE) 
+        return status;
+    (*size) = groups_count;
+    array_for_list=(hythread_group_t*)malloc(sizeof(hythread_group_t)*groups_count);
+    if(array_for_list==NULL)
+    { 
+        status=hythread_global_unlock();
+        return TM_ERROR_OUT_OF_MEMORY;
+    }
+    for (cur = group_list->next; cur != group_list; cur = cur->next)
+    {
+        array_for_list[i++]=cur;
+    }
+    (*list)=array_for_list;
+    status=hythread_global_unlock();
+    return status;   
+}
+
+//@}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_groups.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,82 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.7 $
+ */  
+
+/**
+ * @file thread_native_interrupt.c
+ * @brief Hythread interruption related functions
+ */
+
+#include "thread_private.h"
+#include <open/hythread_ext.h>
+
+/** 
+ * Interrupt a thread.
+ * 
+ * If the thread is currently blocked (i.e. waiting on a monitor_wait or sleeping)
+ * resume the thread and cause it to return from the blocking function with
+ * HYTHREAD_INTERRUPTED.
+ * 
+ * @param[in] thread a thead to be interrupted
+ * @return none
+ */
+void VMCALL hythread_interrupt(hythread_t thread) {
+    IDATA status;
+    thread->state |= TM_THREAD_STATE_INTERRUPTED;
+    
+    // If thread was doing any kind of wait, notify it.
+    if (thread->current_condition) {
+            status=hycond_notify(thread->current_condition);   
+                        assert (status == TM_ERROR_NONE);
+    }
+}
+
+/** 
+ *  Returns interrupted status and clear interrupted flag.
+ *
+ * @param[in] thread where to clear interrupt flag
+ * @returns TM_ERROR_INTERRUPT if thread was interruped, TM_ERROR_NONE otherwise
+ */
+UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread) {
+        int interrupted = thread->state & TM_THREAD_STATE_INTERRUPTED;
+    thread->state &= ~TM_THREAD_STATE_INTERRUPTED;    
+        return interrupted?TM_ERROR_INTERRUPT:TM_ERROR_NONE;
+}
+
+/**
+ * Clear the interrupted flag of the current thread and return its previous value.
+ * 
+ * @return  previous value of interrupted flag: non-zero if the thread had been interrupted.
+ */
+UDATA VMCALL hythread_clear_interrupted() {
+        return hythread_clear_interrupted_other(tm_self_tls);
+}
+
+/**
+ * Return the value of a thread's interrupted flag.
+ * 
+ * @param[in] thread thread to be queried
+ * @return 0 if not interrupted, non-zero if interrupted
+ */
+UDATA VMCALL hythread_interrupted(hythread_t thread) {
+        int interrupted = thread->state & TM_THREAD_STATE_INTERRUPTED;
+        return interrupted?TM_ERROR_INTERRUPT:TM_ERROR_NONE;
+}
+

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,110 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Nikolay Kuznetsov
+ * @version $Revision: 1.1.2.6 $
+ */  
+
+/**
+ * @file thread_native_iterator.c
+ * @brief Hythread iterator related functions
+ */
+
+#undef LOG_DOMAIN
+#define LOG_DOMAIN "tm.iterator"
+
+#include "thread_private.h"
+#include <open/hythread_ext.h>
+
+
+/**
+ * Creates the iterator that can be used to retrieve all threads in the specific group.
+ * 
+ * @param[in] group thread group number
+ */
+hythread_iterator_t VMCALL hythread_iterator_create(hythread_group_t group) {
+        IDATA status;
+    status=hythread_global_lock();
+        assert (status == TM_ERROR_NONE);
+    group = (group)?group:TM_DEFAULT_GROUP;
+    TRACE(("TM iterator created: %p head: %p", group->thread_list, group->thread_list->next));
+    return (hythread_iterator_t)group->thread_list->next;
+}
+
+/**
+ * Releases the iterator over the specific thread group.
+ * 
+ * @param[in] it thread group iterator
+ */
+IDATA VMCALL hythread_iterator_release(hythread_iterator_t *it) {
+    TRACE(("TM iterator released: %p", (*it)->group->thread_list));
+    return hythread_global_unlock();
+}
+
+/**
+ * Resets the iterator such that it will start from the beginning.
+ * 
+ * @param[in] it thread group iterator
+ */
+IDATA VMCALL hythread_iterator_reset(hythread_iterator_t *it) {
+   (*it) = (*it)->group->thread_list->next;
+   TRACE(("TM iterator reset: %p head: %p", (*it)->group->thread_list, (*it))); 
+   return TM_ERROR_NONE;   
+}
+
+/**
+ * Returns the next element in the thread group traversed 
+ * by the given iterator.
+ * 
+ * @param[in] it thread group iterator
+ */
+hythread_t VMCALL hythread_iterator_next(hythread_iterator_t *it) {
+    hythread_t res;
+    
+    if ((*it) == ((hythread_t)*it)->group->thread_list) {
+        TRACE(("TM iterator %p next: NULL", (*it)->group->thread_list));
+        return NULL;
+    } 
+    
+    res = *it;
+    (*it) = (*it)->next;
+    TRACE(("TM iterator %p next: %p", (*it)->group->thread_list, res));
+    return res;
+} 
+
+/**
+ * Returns true if there is next element in a list.
+ * 
+ * @param[in] it thread group iterator
+ */
+IDATA VMCALL hythread_iterator_has_next(hythread_iterator_t it) {
+    IDATA res = (it != ((hythread_t)it)->group->thread_list)? 1 : 0 ;
+    TRACE(("TM iterator %p has next: %d", it->group->thread_list, res));
+    return res;
+    
+}
+
+/**
+ * Returns the size of a list traversed by the given iterator.
+ * 
+ * @param[in] iterator thread group iterator
+ */
+IDATA VMCALL hythread_iterator_size(hythread_iterator_t iterator) {
+    IDATA size = ((hythread_t )iterator)->group->threads_count;
+    TRACE(("TM iterator %p size: %d", iterator->group->thread_list, size));
+    return size;
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_iterator.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,219 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.7 $
+ */  
+
+/**
+ * @file thread_native_latch.c
+ * @brief Hythread latch related functions
+ */
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+
+/**
+ * Creates new latch.
+ *
+ * Latch allows one or more threads to wait until a set of operations 
+ * being performed in other threads are complete. Latch serves as a gate for the threads 
+ * which are waiting until it is opened. Latch initialized to N counts can be used 
+ * to make one thread wait until N threads have completed some action, or some
+ * action has been performed N times.
+ * The key difference between latch and traditional semaphore is that latch notifies 
+ * every waiting threads when it reaches zero, while semaphore notifies only one waiting thread.
+ *
+ * @param[out] latch the memory address where the newly created latch 
+ *        will be stored
+ * @param[in] count the created key
+ * @sa java.util.concurrent.CountDownLatch 
+ */
+IDATA VMCALL hylatch_create(hylatch_t *latch, IDATA count) {
+    hylatch_t l;
+    apr_pool_t *pool = get_local_pool(); 
+        apr_status_t apr_status;
+        
+        l = apr_palloc(pool, sizeof(HyLatch));
+        if(l == NULL) {
+                return TM_ERROR_OUT_OF_MEMORY;
+        }
+    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+        
+    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool);
+
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+
+        l->count = count;
+        l->pool = pool;
+        *latch = l;
+    return TM_ERROR_NONE;
+}
+
+//wait method implementation
+////
+static IDATA latch_wait_impl(hylatch_t latch, I_64 ms, IDATA nano, IDATA interruptable) {
+    IDATA status;
+        
+        status = hymutex_lock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        while (latch->count) {
+                status = condvar_wait_impl(latch->condition, latch->mutex, ms, nano, interruptable);
+                //check interruption and other problems
+                if (status != TM_ERROR_NONE) {
+                        hymutex_unlock(latch->mutex);
+                        return status;
+                }
+
+        if (ms || nano) break;
+        }
+        status = hymutex_unlock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Instructs the current thread to wait until the latch is opened.
+ * 
+ * @param[in] latch the latch to wait for
+ * @sa java.util.concurrent.CountDownLatch.await() 
+ * @return  
+ *      TM_NO_ERROR on success 
+ */
+IDATA VMCALL hylatch_wait(hylatch_t latch) {
+    return latch_wait_impl(latch, 0, 0, WAIT_NONINTERRUPTABLE);       
+}
+/**
+ * Instructs the current thread to wait until the latch is opened or
+ * the specified timeout is elapsed.
+ *
+ * @param[in] latch the latch to wait for
+ * @param[in] ms amount of time in milliseconds to wait
+ * @param[in] nano amount of time in nanoseconds to wait 
+ * @sa java.util.concurrent.CountDownLatch.await()
+ * @return  
+ *      TM_NO_ERROR on success 
+ */
+IDATA VMCALL hylatch_wait_timed(hylatch_t latch, I_64 ms, IDATA nano){
+    return latch_wait_impl(latch, ms, nano, WAIT_NONINTERRUPTABLE);       
+}
+
+/**
+ * Instructs the current thread to wait until the latch is opened or
+ * the specified timeout is elapsed.
+ *
+ * @param[in] latch the latch to wait for
+ * @param[in] ms amount of time in milliseconds to wait
+ * @param[in] nano amount of time in nanoseconds to wait 
+ * @sa java.util.concurrent.CountDownLatch.await()
+ * @return  
+ *      TM_NO_ERROR on success 
+ *      TM_THREAD_INTERRUPTED in case thread was interrupted during wait.
+ */
+IDATA VMCALL hylatch_wait_interruptable(hylatch_t latch, I_64 ms, IDATA nano){
+    return latch_wait_impl(latch, ms, nano, WAIT_INTERRUPTABLE);       
+}
+
+/**
+ * Sets the count for latch to the specific value.
+ *
+ * @param[in] latch the latch 
+ * @param[in] count new count value
+ */
+IDATA VMCALL hylatch_set(hylatch_t latch, IDATA count) {
+        IDATA status;
+        
+        status = hymutex_lock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        latch->count = count;
+        status = hymutex_unlock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;       
+}
+
+/**
+ * Decreases the count for latch.
+ *
+ * If the count reaches zero, all threads awating on the latch are unblocked.
+ * @param[in] latch the latch 
+ * @sa java.util.concurrent.CountDownLatch.countDown()
+ */
+IDATA VMCALL hylatch_count_down(hylatch_t latch){
+        IDATA status;
+        
+        status = hymutex_lock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        if(latch->count <= 0) {
+                status = hymutex_unlock(latch->mutex);
+                if (status != TM_ERROR_NONE) return status;
+                return TM_ERROR_ILLEGAL_STATE;
+        }
+        latch->count--;
+        if(latch->count == 0) {
+                status = hycond_notify_all(latch->condition); 
+                if (status != TM_ERROR_NONE){
+                        hymutex_unlock(latch->mutex);
+                        return status;
+                }
+        }
+                
+        status = hymutex_unlock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        
+    return TM_ERROR_NONE;       
+}
+
+/**
+ * Returns the count for this latch.
+ *
+ * The count value for the latch determines how many times it needs to be counted down
+ * before the threads awaiting on the latch can be unblocked.
+ * @param[out] count count value
+ * @param[in] latch the latch 
+ */
+IDATA VMCALL hylatch_get_count(IDATA *count, hylatch_t latch){
+        IDATA status;
+        
+        status = hymutex_lock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        *count = latch->count;
+        status = hymutex_unlock(latch->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;       
+}
+/**
+ * Destroys the latch and releases the associated memory.
+ * 
+ * @param[in] latch the latch 
+ */
+IDATA VMCALL hylatch_destroy(hylatch_t latch){
+    apr_pool_t *pool = latch->pool;
+    if(pool != get_local_pool()) {
+        return local_pool_cleanup_register(hylatch_destroy, latch);
+    }
+    apr_thread_mutex_destroy((apr_thread_mutex_t*)latch->mutex);
+    apr_thread_cond_destroy((apr_thread_cond_t*)latch->condition);
+    // apr_pool_free(pool, latch);
+
+    return TM_ERROR_NONE;       
+}
+

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,115 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.8 $
+ */  
+
+/**
+ * @file thread_native_mutex.c
+ * @brief Hythread mutex related functions
+ */
+
+#undef LOG_DOMAIN
+#define LOG_DOMAIN "tm.locks"
+
+#include "thread_private.h"
+#include <open/hythread_ext.h>
+
+
+/** @name Mutex
+ *  
+ */
+//@{
+
+/**
+ * Creates and initializes a mutex.
+ *
+ * Mutex is a fat lock which implies parking of threads in case of contention.
+ * @param[in] mutex the memory address where the newly created mutex will be
+ *        stored.
+ * @param[in] flags Or'ed value of:
+ * <PRE>
+ *           HYTHREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
+ *           HYTHREAD_MUTEX_NESTED    enable nested (recursive) locks.
+ *           HYTHREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
+ * </PRE>
+ * @sa apr_thread_mutex_create()
+ */
+IDATA VMCALL hymutex_create (hymutex_t *mutex, UDATA flags) {
+    apr_pool_t *pool = get_local_pool(); 
+        apr_status_t apr_status;
+        
+    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)mutex, flags, pool);
+
+        return CONVERT_ERROR(apr_status);
+}
+
+/**
+ * Acquires the lock for the given mutex. If the mutex is already locked,
+ * the current thread will be put to sleep until the lock becomes available.
+ *
+ * @param[in] mutex the mutex on which to acquire the lock.
+ * @sa apr_thread_mutex_lock()
+ */
+IDATA VMCALL hymutex_lock(hymutex_t mutex) {
+        apr_status_t apr_status;
+        apr_status = apr_thread_mutex_lock((apr_thread_mutex_t*)mutex);
+
+    return CONVERT_ERROR(apr_status);
+}
+
+/**
+ * Attempts to acquire the lock for the given mutex. 
+ *
+ * @param[in] mutex the mutex on which to attempt the lock acquiring.
+ * @sa apr_thread_mutex_trylock()
+ */
+IDATA VMCALL hymutex_trylock (hymutex_t mutex) {
+    return CONVERT_ERROR(apr_thread_mutex_trylock((apr_thread_mutex_t*)mutex));
+}
+
+/**
+ * Releases the lock for the given mutex.
+ *
+ * @param[in] mutex the mutex from which to release the lock.
+ * @sa apr_thread_mutex_unlock()
+ */
+IDATA VMCALL hymutex_unlock (hymutex_t mutex) {
+        apr_status_t apr_status = apr_thread_mutex_unlock((apr_thread_mutex_t*)mutex);
+        assert(apr_status == APR_SUCCESS);
+    return CONVERT_ERROR(apr_status);
+}
+
+/**
+ * Destroys the mutex and releases the memory associated with the lock.
+ *
+ * @param[in] mutex the mutex to destroy.
+ * @sa apr_thread_mutex_destroy()
+ */
+IDATA VMCALL hymutex_destroy (hymutex_t mutex) {
+        apr_pool_t *pool = apr_thread_mutex_pool_get ((apr_thread_mutex_t*)mutex);
+        apr_status_t apr_status;
+    if(pool != get_local_pool()) {
+        return local_pool_cleanup_register(hymutex_destroy, mutex);
+    }
+    apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)mutex);
+    return CONVERT_ERROR(apr_status);
+}
+
+
+//@}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,73 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Nikolay Kuznetsov
+ * @version $Revision: 1.1.2.7 $
+ */  
+
+/**
+ * @file thread_native_park.c
+ * @brief Hythread park/unpark related functions
+ */
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+
+/**
+ * 'Park' the current thread. 
+ * 
+ * Stop the current thread from executing until it is unparked, interrupted, or the specified timeout elapses.
+ * 
+ * Unlike wait or sleep, the interrupted flag is NOT cleared by this API.
+ *
+ * @param[in] millis
+ * @param[in] nanos 
+ * 
+ * @return 0 if the thread is unparked
+ * HYTHREAD_INTERRUPTED if the thread was interrupted while parked<br>
+ * HYTHREAD_PRIORITY_INTERRUPTED if the thread was priority interrupted while parked<br>
+ * HYTHREAD_TIMED_OUT if the timeout expired<br>
+ *
+ * @see hythread_unpark
+ */
+IDATA VMCALL hythread_park(I_64 millis, IDATA nanos) {
+     hythread_t t = tm_self_tls;     
+     assert(t);
+     return hysem_wait_interruptable(t->park_event, millis, nanos);
+}
+
+/**
+ * 'Unpark' the specified thread. 
+ * 
+ * If the thread is parked, it will return from park.
+ * If the thread is not parked, its 'UNPARKED' flag will be set, and it will return
+ * immediately the next time it is parked.
+ *
+ * Note that unparks are not counted. Unparking a thread once is the same as unparking it n times.
+ * 
+ * @see hythread_park
+ */
+void VMCALL hythread_unpark(hythread_t thread) {
+    IDATA UNUSED status;
+    if(thread ==  NULL) {
+        return;
+    }
+    
+    status = hysem_post(thread->park_event);
+        assert(status == TM_ERROR_NONE);
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,241 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.8 $
+ */  
+
+/**
+ * @file thread_native_semaphore.c
+ * @brief Hythread semaphore related functions
+ */
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+/**
+ * Initializes unnamed process-private semaphore.
+ *
+ * @param[out] sem new semaphore
+ * @param[in] initial_count initial semaphore count
+ * @param[in] max_count  maximum semaphore count
+ */
+IDATA VMCALL hysem_create(hysem_t *sem, unsigned initial_count, unsigned max_count) {
+    hysem_t l;
+    apr_pool_t *pool = get_local_pool(); 
+        apr_status_t apr_status;
+        
+        l = apr_palloc(pool, sizeof(HySemaphore));
+        if(l == NULL) {
+                return TM_ERROR_OUT_OF_MEMORY;
+        }
+    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+        
+    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool);
+
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+        l->count = initial_count;
+        l->max_count = max_count;
+        l->pool = pool;
+        *sem = l;
+    return TM_ERROR_NONE;
+}
+
+
+IDATA sem_wait_impl(hysem_t sem, I_64 ms, IDATA nano, IDATA interruptable) {
+    IDATA status;
+        
+        status = hymutex_lock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+    //printf("wait %x %d\n", sem, sem->count);
+        //fflush(NULL);
+        while (sem->count<=0) {
+                status = condvar_wait_impl(sem->condition, sem->mutex, ms, nano, interruptable);
+                //check interruption and timeout
+                if(status != TM_ERROR_NONE) {
+                        hymutex_unlock(sem->mutex);
+                        return status;
+                }
+
+        if (nano || ms) break;
+        }
+    //should we check here if timeout is not supposet to happen
+        if(sem->count==0 /*&& (ms || nano)*/)
+        {
+                if (ms || nano) {
+                        hymutex_unlock(sem->mutex);
+                        return TM_ERROR_TIMEOUT;
+                } else {
+                        assert(0);
+                }
+        }
+        sem->count--;
+        status = hymutex_unlock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Wait on a semaphore.
+ *
+ * @param[in] s semaphore to be waited on
+ * @return  0 on success or negative value on failure
+ *
+ * @deprecated Semaphores are no longer supported.
+ *
+ * @see hysem_init, hysem_destroy, hysem_wait
+ *
+ */
+IDATA VMCALL hysem_wait(hysem_t sem) {   
+    return sem_wait_impl(sem, 0, 0, WAIT_NONINTERRUPTABLE);
+}
+
+/**
+ * Decreases the count of the semaphore and waits until the semaphore reaches zero with the specified timeout.
+ *
+ *
+ * @param[in] sem semaphore
+ * @param[in] ms timeout millis
+ * @param[in] nano timeout nanos
+ * @return  
+ *      TM_NO_ERROR on success 
+ */
+IDATA VMCALL hysem_wait_timed(hysem_t sem, I_64 ms, IDATA nano) {
+    return sem_wait_impl(sem, ms, nano, WAIT_NONINTERRUPTABLE);
+}
+
+/**
+ * Decreases the count of the semaphore and waits until the semaphore reaches zero with the specified timeout.
+ *
+ *
+ * @param[in] sem semaphore
+ * @param[in] ms timeout millis
+ * @param[in] nano timeout nanos
+ * @return  
+ *      TM_NO_ERROR on success 
+ *      TM_THREAD_INTERRUPTED in case thread was interrupted during wait.
+ */
+IDATA VMCALL hysem_wait_interruptable(hysem_t sem, I_64 ms, IDATA nano) {
+    return sem_wait_impl(sem, ms, nano, WAIT_INTERRUPTABLE);
+}
+
+/**
+ * Release a semaphore by 1.
+ *
+ * @param[in] s semaphore to be released by 1
+ * @return  0 on success or negative value on failure
+ *
+ * @deprecated Semaphores are no longer supported.
+ *
+ * @see hysem_init, hysem_destroy, hysem_wait
+ */
+IDATA VMCALL hysem_post(hysem_t sem) {
+        IDATA status;
+    //printf("post %x %d\n", sem, sem->count);
+//      fflush(NULL);
+        status = hymutex_lock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        if(sem->count >= sem->max_count) {
+                hymutex_unlock(sem->mutex);
+        //printf("illegal state %d : %d \n", sem->count, sem->max_count);
+        //fflush(NULL);
+                return TM_ERROR_ILLEGAL_STATE;
+        }
+        sem->count++;
+        if(sem->count > 0) {
+                hycond_notify(sem->condition);
+        }
+                
+        status = hymutex_unlock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Resets current semaphore count to the specifed numbers.
+ *
+ * @param[in] count new semaphore count
+ * @param[in] sem semaphore
+ */
+IDATA VMCALL hysem_set(hysem_t sem, IDATA count) {
+        IDATA status;
+        
+        status = hymutex_lock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        if(count > sem->max_count) {
+                hymutex_unlock(sem->mutex);
+                if (status != TM_ERROR_NONE) return status;
+                return TM_ERROR_ILLEGAL_STATE;
+        }
+        sem->count = count;
+        if(count > 0) {
+                status = hycond_notify_all(sem->condition); 
+                if (status != TM_ERROR_NONE){
+                        hymutex_unlock(sem->mutex);
+                        return status;
+                }
+        }
+        status = hymutex_unlock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;       
+}
+
+/**
+ * Returns current count for semaphore.
+ *
+ * @param[out] count semaphore count
+ * @param[in] sem semaphore
+ */
+IDATA VMCALL hysem_getvalue(int *count, hysem_t sem) {
+        IDATA status;
+        
+        status = hymutex_lock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+        *count = sem->count;
+        status = hymutex_unlock(sem->mutex);
+        if (status != TM_ERROR_NONE) return status;
+
+    return TM_ERROR_NONE;      
+}
+
+/**
+ * Destroy a semaphore.
+ *
+ * Returns the resources associated with a semaphore back to the Hy threading library.
+ *
+ * @param[in] s semaphore to be destroyed
+ * @return  0 on success or negative value on failure
+ *
+ * @deprecated Semaphores are no longer supported.
+ *
+ * @see hysem_init, hysem_wait, hysem_post
+ */
+IDATA VMCALL hysem_destroy(hysem_t sem) {
+        apr_status_t apr_status;
+    apr_pool_t *pool = sem->pool;
+    if(pool != get_local_pool()) {
+        return local_pool_cleanup_register(hysem_destroy, sem);
+    }
+    apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)sem->mutex);
+        if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)sem->condition);
+    // apr_pool_free(pool, sem);
+    return CONVERT_ERROR(apr_status);;
+}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_state.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_state.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_state.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_state.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,114 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Andrey Chernyshev
+ * @version $Revision: 1.1.2.4 $
+ */  
+
+/**
+ * @file thread_native_state.c
+ * @brief Hythread state related functions
+ */
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+
+/**
+ * Returns non-zero if thread is currently alive.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_alive(hythread_t thread) { 
+        return thread->state & TM_THREAD_STATE_ALIVE;  
+};
+
+/**
+ * Returns non-zero if thread is blocked on monitor enter.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_blocked_on_monitor_enter(hythread_t thread) { return thread->state & TM_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER ;  };
+
+/**
+ * Returns non-zero if thread is waiting on monitor.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_in_monitor_wait(hythread_t thread) { return thread->state & TM_THREAD_STATE_IN_MONITOR_WAIT ;  };
+
+/**
+ * Returns non-zero if thread is in native.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_in_native(hythread_t thread) { return thread->state & TM_THREAD_STATE_IN_NATIVE ;  };
+
+/**
+ * Returns non-zero if thread is parked.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_parked(hythread_t thread) { return thread->state & TM_THREAD_STATE_PARKED ;  };
+
+/**
+ * Returns non-zero if thread is runnable.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_runnable(hythread_t thread) { return thread->state & TM_THREAD_STATE_RUNNABLE;  };
+
+/**
+ * Returns non-zero if thread is sleeping.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_sleeping(hythread_t thread) { return thread->state & TM_THREAD_STATE_SLEEPING ;  };
+
+/**
+ * Returns non-zero if thread is suspended.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_suspended(hythread_t thread) { return thread->state & TM_THREAD_STATE_SUSPENDED ;  };
+
+/**
+ * Returns non-zero if thread is terminated.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_terminated(hythread_t thread) { return thread->state & TM_THREAD_STATE_TERMINATED ;  };
+
+/**
+ * Returns non-zero if thread is waiting.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_waiting(hythread_t thread) { return thread->state & TM_THREAD_STATE_WAITING ;  };
+
+/**
+ * Returns non-zero if thread is waiting indefinitly.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_waiting_indefinitely(hythread_t thread) { return thread->state & TM_THREAD_STATE_WAITING_INDEFINITELY ;  };
+
+/**
+ * Returns non-zero if thread is waiting with timeout.
+ *
+ * @param[in] thread those attribute is read
+ */
+int VMCALL hythread_is_waiting_with_timeout(hythread_t thread) { return thread->state & TM_THREAD_STATE_WAITING_WITH_TIMEOUT ;  };

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_state.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?rev=434076&view=auto
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Wed Aug 23 09:48:41 2006
@@ -0,0 +1,435 @@
+/*
+ *  Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/** 
+ * @author Artem Aliev
+ * @version $Revision: 1.1.2.11 $
+ */
+
+/**
+ * @file thread_native_suspend.c
+ * @brief Hythread suspend/resume related functions
+ */
+
+#undef LOG_DOMAIN
+#define LOG_DOMAIN "tm.suspend"
+
+#include <open/hythread_ext.h>
+#include "thread_private.h"
+#include "apr_thread_ext.h"
+
+
+static void thread_safe_point_impl(hythread_t thread);
+
+/** @name Safe suspension support
+ */
+//@{
+
+/**
+ * Returns non-zero if thread is suspended.
+ */
+IDATA VMCALL hythread_is_suspend_enabled(){
+        return tm_self_tls->suspend_disable_count == 0;
+}
+
+
+/**
+ * Denotes the beginning of the code region where safe suspension is possible.
+ *
+ * First, this method sets the suspend_enabled state flag to true.
+ * If there was a suspension request set for this thread, this method notifies the 
+ * requesting thread that a safe region is reached.
+ * <p>
+ * A thread marks itself with functions tmn_suspend_enable() and tmn_suspend_disable() in order
+ * to denote a safe region of code. It may also call safe_point() method to denote a selected 
+ * point where safe suspension is possible.
+ */
+void VMCALL hythread_suspend_enable() {
+    register hythread_t thread;
+    assert(!hythread_is_suspend_enabled());
+
+#ifdef FS14_TLS_USE
+    __asm { 
+         mov eax, fs:[0x14] 
+         dec [eax]HyThread.suspend_disable_count
+         mov eax, [eax]HyThread.suspend_request
+         test eax, eax
+         jnz suspended
+        
+    } 
+    return;
+
+suspended:
+    thread=tm_self_tls;
+
+#else 
+    thread=tm_self_tls;
+    thread->suspend_disable_count--;
+#endif
+    if(!thread->suspend_request  || thread->suspend_disable_count!=0) {
+        return;
+    }
+        
+    hylatch_count_down(thread->safe_region_event);
+}
+
+/**
+ * Denotes the end of the code region where safe suspension was possible.
+ *
+ * This method sets the suspend_enabled state flag to false and then invokes
+ * tmn_safe_point().
+ * <p>
+ * A thread marks itself with functions tmn_suspend_enable() and tmn_suspend_disable() in order
+ * to denote a safe region of code. It may also call safe_point() method to denote a selected 
+ * point where safe suspension is possible.
+ */
+void VMCALL hythread_suspend_disable()
+{   
+    register hythread_t thread;
+
+#ifdef FS14_TLS_USE
+    __asm { 
+         mov eax, fs:[0x14] 
+         inc [eax]HyThread.suspend_disable_count
+         mov eax, [eax]HyThread.suspend_request
+         test eax, eax
+         jnz suspended
+        
+    } 
+    return;
+
+suspended:
+    thread=tm_self_tls;
+
+#else 
+    thread=tm_self_tls;
+    thread->suspend_disable_count++;
+#endif
+
+    if(!thread->suspend_request  || thread->suspend_disable_count!=1) {
+        return;
+    }
+    thread_safe_point_impl(thread);
+}
+
+
+
+/**
+ * Denotes a single point where safe suspension is possible.
+ *
+ * If there was a suspension request set for this thread, this method notifes
+ * the requesting thread and then blocks until someone calls the tmn_resume() 
+ * for this thread.
+ * <p>
+ * A thread marks itself with functions tmn_suspend_enable() and tmn_suspend_disable() in order
+ * to denote a safe region of code. It may also call safe_point() method to denote a selected 
+ * point where safe suspension is possible.
+ */
+void VMCALL hythread_safe_point() {
+    thread_safe_point_impl(tm_self_tls);
+}
+
+static void thread_safe_point_impl(hythread_t thread) { 
+    if(thread->suspend_request >0) {   
+        
+                int old_status = thread->suspend_disable_count;
+                do {
+            TRACE(("TM: safe point enter: thread: %p count: %d dis count: %d", 
+                        thread, thread->suspend_request, thread->suspend_disable_count));
+            
+                        thread->suspend_disable_count = 0;
+
+            if (thread->safepoint_callback) {
+                thread->safepoint_callback();
+            }
+            
+                        apr_memory_rw_barrier();
+                        // code for Ipf that support StackIterator and immmediate suspend
+                        // notify suspender
+                    hylatch_count_down(thread->safe_region_event);
+
+                // wait for resume event
+            hysem_wait(thread->resume_event);
+            TRACE(("TM: safe point resume: thread: %p count: %d", thread, thread->suspend_request));
+
+            thread->suspend_disable_count = old_status;
+            apr_memory_rw_barrier();
+                } while (thread->suspend_request >0);
+     }
+} // thread_safe_point_impl
+
+
+// the function start suspension.
+// call wait_safe_region_event() should be called to wait for safe region or safe point.
+// the function do not suspend self.
+static void send_suspend_request(hythread_t thread) {
+
+                assert(thread->suspend_request >=0);
+                // already suspended?
+        if(thread->suspend_request > 0) {
+                        thread->suspend_request++;
+                        return;
+                }               
+                
+                //we realy need to suspend thread.
+
+                hysem_set(thread->resume_event, 0);
+                
+                thread->suspend_request++;
+                apr_memory_rw_barrier();
+            apr_thread_yield_other(thread->os_handle);
+
+        TRACE(("TM: suspend requiest sent: %p request count: %d",thread , thread->suspend_request));
+}
+
+
+// the second part of suspention
+// blocked in case was selfsuspended.
+static void wait_safe_region_event(hythread_t thread) {
+                assert(thread->suspend_request >= 1);
+        if(thread->suspend_request > 1 || thread == tm_self_tls) {
+            TRACE(("TM: suspend wait self exit thread: %p request count: %d",thread , thread->suspend_request));
+                        return;
+                }               
+ 
+                // we need to wait for notification only in case the thread is in the unsafe/disable region
+                while (thread->suspend_disable_count) {
+                        // wait for the notification
+                        hylatch_wait_timed(thread->safe_region_event, 50, 0);
+                }
+        TRACE(("TM: suspend wait exit safe region thread: %p request count: %d",thread , thread->suspend_request));
+                thread->state |= TM_THREAD_STATE_SUSPENDED;
+}
+
+/**
+ * Suspends the current thread. 
+ * 
+ * Stop the current thread from executing until it is resumed.
+ * 
+ * @return none
+ *
+ * @see hythread_resume
+ */
+void VMCALL hythread_suspend() {
+    hythread_t self = tm_self_tls;
+    hythread_global_lock();
+        self->suspend_request++;
+        hythread_global_unlock();
+        hythread_safe_point();
+}
+
+
+/**
+ * Safely suspends the <code>thread</code> execution.
+ *
+ * This method is a SAFE_POINT
+ *
+ * The safe suspension acts as follows:
+ * <ul>
+ * <li>
+ * If the <code>thread</code> is currently running in safe code region, this
+ * method immediately returns back.
+ * The <code>thread</code> itself runs until it reaches the end of safe region
+ * and then blocks until someone calls tmn_resume() for it.
+ * <li>
+ * If the <code>thread</code> is currently in unsafe region, this
+ * method blocks until the <code>thread</code> either reaches the beginning 
+ * of a safe region, or reaches a safe point. 
+ * Once reached safe point or end of safe region, the<code>thread</code> blocks 
+ * until someone calls tmn_resume() for it.
+ * </ul>
+ * A thread marks itself with functions tmn_suspend_enable() and tmn_suspend_disable() in order
+ * to denote a safe region of code. It may also call safe_point() method to denote a selected 
+ * point where safe suspension is possible.
+ *
+ * @param[in] thread thread to be suspended
+ */
+void VMCALL hythread_suspend_other(hythread_t thread) {
+    hythread_t self;
+    hythread_global_lock();
+    self = tm_self_tls;
+    
+    TRACE(("TM: suspend one enter thread: %p request count: %d",thread , thread->suspend_request));
+    if(self == thread) {
+        hythread_global_unlock();
+        hythread_suspend();
+        return; 
+    }
+    // try to prevent cyclic suspend dead-lock
+    //while(self->suspend_request > 0) {
+    //    hythread_global_unlock();
+    //    thread_safe_point_impl(self);
+    //    hythread_global_lock();
+    //}
+
+        send_suspend_request(thread);
+        wait_safe_region_event(thread);
+    hythread_global_unlock();
+    TRACE(("TM: suspend one exit thread: %p request count: %d",thread , thread->suspend_request));
+        
+    return;
+}
+
+/**
+ * Resume a thread.
+ *
+ * Take a threads out of the suspended state.
+ *
+ * If the thread is not suspended, no action is taken.
+ *
+ * @param[in] thread a thread to be resumed
+ * @return none
+ *
+ * @see hythread_create, hythread_suspend
+ */
+void VMCALL hythread_resume(hythread_t thread) {
+     hythread_global_lock();
+        TRACE(("TM: start resuming: %p request count: %d",thread , thread->suspend_request));
+    // If there was request for suspension, decrease the request counter
+    if(thread->suspend_request > 0) {
+        thread->suspend_request--;
+        // If no more requests left, thread needs to be resumed
+        if(thread->suspend_request == 0) {  
+            // Notify the thread that it may wake up now
+            hysem_post(thread->resume_event);            
+            TRACE(("TM: resume one thread: %p request count: %d",thread , thread->suspend_request));
+            thread->state &= ~TM_THREAD_STATE_SUSPENDED;
+        }
+    }
+    hythread_global_unlock();
+}
+
+/**
+ * Sets safepoint callback function.
+ * 
+ * Callback function is executed at safepoint in case there was a suspension request.
+ *  
+ * @param[in] thread thread where callback needs to be executed
+ * @param[in] callback callback function
+ */
+IDATA set_safepoint_callback(hythread_t thread, tm_thread_event_callback_proc callback) {
+    // not implemented
+    thread->safepoint_callback = callback;      
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Returns safepoint callback function.
+ * 
+ * @param[in] t thread where callback needs to be executed
+ * @return callback function currently instralled, or NULL if there was none
+ */
+hythread_event_callback_proc VMCALL hythread_get_safepoint_callback(hythread_t t) {
+    return t->safepoint_callback;
+}
+
+/**
+ * Helps to safely suspend the threads in the selected group.
+ *
+ * This method sets a suspend request for the every thread in the group 
+ * and then returns the iterator that can be used to traverse through the suspended threads.
+ * Each invocation of the tmn_iterator_next() method on the iterator will return the next 
+ * suspeneded thread.
+ *
+ * @param[out] t iterator 
+ * @param[in] group thread group to be suspended
+ */
+IDATA VMCALL hythread_suspend_all(hythread_iterator_t *t, hythread_group_t group) {
+    hythread_t self = tm_self_tls;
+    hythread_t next;
+    hythread_iterator_t iter;
+    
+    TRACE(("TM: suspend all"));
+    self = tm_self_tls;
+    // try to prevent cyclic suspend dead-lock
+    while(self->suspend_request > 0) {
+        thread_safe_point_impl(self);
+    }
+        
+        iter = hythread_iterator_create(group);
+        // send suspend requests to all threads
+    TRACE(("TM: send suspend requests"));
+        while((next = hythread_iterator_next(&iter)) != NULL) {
+                if(next != self) {
+                        send_suspend_request(next);
+                }       
+        }
+        
+        hythread_iterator_reset(&iter);
+        // all threads should be stoped in safepoints or be in safe region.
+    TRACE(("TM: wait suspend responses"));
+        while((next = hythread_iterator_next(&iter)) != NULL) {
+                if(next != self) {
+                        wait_safe_region_event(next);
+                }       
+        }
+        
+        hythread_iterator_reset(&iter);
+        hythread_iterator_release(&iter);
+        if(t) {
+                *t=iter;
+        }
+    return TM_ERROR_NONE;
+}
+
+
+
+/**
+ * Resumes all threads in the selected group.
+ *
+ * @param[in] group thread group to be resumed
+ */
+IDATA VMCALL hythread_resume_all(hythread_group_t  group) {
+    hythread_t self = tm_self_tls;
+    hythread_t next;
+        hythread_iterator_t iter = hythread_iterator_create(group);
+    TRACE(("TM: resume all"));
+        // send suspend requests to all threads
+        while((next = hythread_iterator_next(&iter)) != NULL) {
+                if(next != self) {
+                        hythread_resume(next);
+                }       
+        }
+        
+        hythread_iterator_release(&iter);       
+    return TM_ERROR_NONE;
+}
+
+
+// Private functionality
+
+int reset_suspend_disable() {
+        hythread_t self = tm_self_tls;
+        int dis = self->suspend_disable_count;
+        self->suspend_disable_count = 0;
+        if(self->suspend_request >0) {   
+        // notify suspender
+        hylatch_count_down(self->safe_region_event);
+    }
+        return dis;
+}
+
+void set_suspend_disable(int count) {
+        hythread_t self = tm_self_tls;
+        assert(count>=0);
+    self->suspend_disable_count = count;
+        if(count) {
+                thread_safe_point_impl(self);
+        }
+}
+
+
+//@}

Propchange: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message