dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 46170787d2b3b5f4793df24e626096433d5d173b
Date: Thu, 31 Dec 2009 12:39:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  46170787d2b3b5f4793df24e626096433d5d173b (commit)
      from  f7f6ba85e15de56ae50c49bf8bae3f1779833243 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=46170787d2b3b5f4793df24e626096433d5d173b

commit 46170787d2b3b5f4793df24e626096433d5d173b
Author: Klaus Treichel <address@hidden>
Date:   Thu Dec 31 13:39:03 2009 +0100

    Move threading error codes and monitor prototypes from private include
    file thr_defs.h to public include file il_thread.h.

diff --git a/ChangeLog b/ChangeLog
index 8b77bd2..06048f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-12-31  Klaus Treichel  <address@hidden>
+
+       * engine/heap.c (_ILFinalizeObject): Reclaim the monitor still attached
+       to a finalized object.
+
+       * include/il_thread.h: Move the threading error code definitions and
+       monitor prototypes from thr_defs.h to here.
+
+       * support/thr_defs.h: Move the threading error code definitions and
+       monitor prototypes to il_thread.h.
+
+       * support/thread.c: Add more debugging support.
+
 2009-12-30  Klaus Treichel  <address@hidden>
 
        * configure.in: Add checks for the nanosleep and clock_nanosleep
diff --git a/engine/heap.c b/engine/heap.c
index 94fc661..5a0cf6e 100644
--- a/engine/heap.c
+++ b/engine/heap.c
@@ -1,7 +1,7 @@
 /*
  * heap.c - Heap routines for the runtime engine.
  *
- * Copyright (C) 2001, 2008  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2001, 2008, 2009  Southern Storm Software, Pty Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -102,7 +102,7 @@ void _ILFinalizeObject(void *block, void *data)
        ILMethod *method;
        ILThread *thread;
        ILExecProcess *process;
-       ILExecThread *execThread;       
+       ILExecThread *execThread;
        ILFinalizationContext *finalizationContext;
        ILThreadExecContext newContext, saveContext;
        
@@ -119,6 +119,13 @@ void _ILFinalizeObject(void *block, void *data)
        if (process == 0)
        {
                /* Our owner process died.  We're orphaned and can't finalize */
+#ifndef IL_CONFIG_USE_THIN_LOCKS
+               /*
+                * We'll look for a monitor that's still attached to the object
+                * anyways and reclaim it if needed.
+                */
+               ILMonitorReclaim((void **)GetObjectLockWordPtr(execThread, 
object));
+#endif
                return;
        }
 
@@ -162,6 +169,14 @@ void _ILFinalizeObject(void *block, void *data)
                }
        }
        
+#ifndef IL_CONFIG_USE_THIN_LOCKS
+       /*
+        * We'll look for a monitor that's still attached to the object
+        * anyways and reclaim it if needed.
+        */
+       ILMonitorReclaim((void **)GetObjectLockWordPtr(execThread, object));
+#endif
+
        /* On multi-threaded systems, the finalizer ILExecThread and main
           ILExecThreads are distinct *but* it is possible for the main
           ILThread to execute finalizers (when synchronous finalization
diff --git a/include/il_thread.h b/include/il_thread.h
index 2fe0f8c..06f4e6f 100644
--- a/include/il_thread.h
+++ b/include/il_thread.h
@@ -1,7 +1,7 @@
 /*
  * il_thread.h - Thread support routines.
  *
- * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2002, 2009  Southern Storm Software, Pty Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -43,6 +43,20 @@ extern       "C" {
 #define        IL_TS_ABORTED                   0x0100
 
 /*
+ * Threading error codes.
+ */
+#define IL_THREAD_OK                                           0x00000000
+#define IL_THREAD_ERR_ABANDONED                                0x00000080
+#define IL_THREAD_ERR_INTERRUPT                                0x000000C0
+#define IL_THREAD_BUSY                                         0x00000102
+#define IL_THREAD_ERR_INVALID_TIMEOUT          0x80131502
+#define IL_THREAD_ERR_SYNCLOCK                         0x80131518
+#define IL_THREAD_ERR_ABORTED                          0x80131530
+#define IL_THREAD_ERR_INVALID_RELEASECOUNT     0xFFFFFFFD
+#define IL_THREAD_ERR_OUTOFMEMORY                      0xFFFFFFFE
+#define IL_THREAD_ERR_UNKNOWN                          0xFFFFFFFF
+
+/*
  * Opaque types for thread-related objects.
  */
 typedef struct _tagILThread     ILThread;
@@ -559,6 +573,63 @@ int ILWaitEventReset(ILWaitHandle *event);
  */
 int ILWaitEventPulse(ILWaitHandle *event);
 
+/*
+ * Enter a monitor 
+ * This function returns IL_THREAD_OK on success, IL_THREAD_BUSY on timeout
+ * or any other of the threading return codes on error.
+ * NOTE: The monitor is only entered if IL_THREAD_OK is returned.
+ * On every other return value the lock is not obtained.
+ * This is because the code used with monitors usually looks like:
+ * Monitor.Enter(obj);
+ * try
+ * {
+ *    do_something
+ * }
+ * finally
+ * {
+ *    Monitor.Exit(obj);
+ * }
+ * So the exception is thrown outside the try/finally handlier that ensures
+ * propper monitor release.
+ */
+int ILMonitorTimedTryEnter(void **monitorLocation, ILUInt32 ms);
+#define ILMonitorEnter(loc)            ILMonitorTimedTryEnter((loc), 
IL_MAX_UINT32)
+#define ILMonitorTryEnter(loc) ILMonitorTimedTryEnter((loc), 0)
+
+/*
+ * Leave the monitor stored at monitorLocation.
+ * This function returns IL_THREAD_OK on success, IL_THREAD_BUSY on timeout
+ * or any other of the threading return codes on error.
+ */
+int ILMonitorExit(void **monitorLocation);
+
+/*
+ * Enter the wait state on an owned monitor.
+ */
+int ILMonitorTimedWait(void **monitorLocation, ILUInt32 ms);
+#define ILMonitorWait(loc)     ILMonitorTimedWait((loc), IL_MAX_UINT32)
+
+/*
+ * Move one thread in the waiting queue to the ready queue in the monitor
+ * stored at monitorLocation.
+ */
+int ILMonitorPulse(void **monitorLocation);
+
+/*
+ * Move all threads in the waiting queue to the ready queue in the monitor
+ * stored at monitorLocation.
+ */
+int ILMonitorPulseAll(void **monitorLocation);
+
+/*
+ * Reclaim the monitor stored at monitorLocation.
+ * This function is used for example if a monitor is attached to an object
+ * that is going to be reclaimed by a garbage collector.
+ * The monitor will not be needed anymore but it's state is undefined.
+ * Reclaiming a monitor is caused by a bug in the using application.
+ */
+void ILMonitorReclaim(void **monitorLocation);
+
 #ifdef __cplusplus 
 };
 #endif
diff --git a/support/thr_defs.h b/support/thr_defs.h
index 831a2c2..663ddd2 100755
--- a/support/thr_defs.h
+++ b/support/thr_defs.h
@@ -2,7 +2,7 @@
 /*
  * thr_defs.h - Common thread definitions.
  *
- * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
+ * Copyright (C) 2002, 2009  Southern Storm Software, Pty Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -33,26 +33,12 @@
 /* #define IL_THREAD_DEBUG */
 
 /*
- * Threading error codes.
- */
-#define IL_THREAD_OK                                           0x00000000
-#define IL_THREAD_ERR_ABANDONED                                0x00000080
-#define IL_THREAD_BUSY                                         0x00000102
-#define IL_THREAD_ERR_INVALID_TIMEOUT          0x80131502
-#define IL_THREAD_ERR_SYNCLOCK                         0x80131518
-#define IL_THREAD_ERR_INTERRUPT                                0x80131519
-#define IL_THREAD_ERR_ABORTED                          0x80131530
-#define IL_THREAD_ERR_INVALID_RELEASECOUNT     0xFFFFFFFD
-#define IL_THREAD_ERR_OUTOFMEMORY                      0xFFFFFFFE
-#define IL_THREAD_ERR_UNKNOWN                          0xFFFFFFFF
-
-/*
  * Choose which thread package we will be using.
  */
 #include "thr_choose.h"
 #include "il_utils.h"
 #include "interrupt.h"
-#ifdef IL_THREAD_ASSERTIONS
+#if defined(IL_THREAD_ASSERTIONS) || defined(IL_THREAD_DEBUG)
 #include <stdio.h>
 #include <stdlib.h>
 #endif
@@ -678,63 +664,6 @@ void _ILMonitorSystemInit();
  */
 void _ILMonitorSystemDeinit();
 
-/*
- * Enter a monitor 
- * This function returns IL_THREAD_OK on success, IL_THREAD_BUSY on timeout
- * or any other of the threading return codes on error.
- * NOTE: The monitor is only entered if IL_THREAD_OK is returned.
- * On every ohter return value the lock is not obtained.
- * This is because the code used with monitors usually looks like:
- * Monitor.Enter(obj);
- * try
- * {
- *    do_something
- * }
- * finally
- * {
- *    Monitor.Exit(obj);
- * }
- * So the exception is thrown outside the try/finally handlier that ensures
- * propper monitor release.
- */
-int ILMonitorTimedTryEnter(void **monitorLocation, ILUInt32 ms);
-#define ILMonitorEnter(loc)            ILMonitorTimedTryEnter((loc), 
IL_MAX_UINT32)
-#define ILMonitorTryEnter(loc) ILMonitorTimedTryEnter((loc), 0)
-
-/*
- * Leave the monitor stored at monitorLocation.
- * This function returns IL_THREAD_OK on success, IL_THREAD_BUSY on timeout
- * or any other of the threading return codes on error.
- */
-int ILMonitorExit(void **monitorLocation);
-
-/*
- * Enter the wait state on an owned monitor.
- */
-int ILMonitorTimedWait(void **monitorLocation, ILUInt32 ms);
-#define ILMonitorWait(loc)     ILMonitorTimedWait((loc), IL_MAX_UINT32)
-
-/*
- * Move one thread in the waiting queue to the ready queue in the monitor
- * stored at monitorLocation.
- */
-int ILMonitorPulse(void **monitorLocation);
-
-/*
- * Move all threads in the waiting queue to the ready queue in the monitor
- * stored at monitorLocation.
- */
-int ILMonitorPulseAll(void **monitorLocation);
-
-/*
- * Reclaim the monitor stored at monitorLocation.
- * This function is used for example if a monitor is attached to an object
- * that is going to be reclaimed by a garbage collector.
- * The monitor will not be needed anymore but it's state is undefined.
- * Reclaiming a monitor is caused by a bug in the using application.
- */
-void ILMonitorReclaim(void **monitorLocation);
-
 #ifdef __cplusplus
 };
 #endif
diff --git a/support/thread.c b/support/thread.c
index 9b809f9..3db7743 100755
--- a/support/thread.c
+++ b/support/thread.c
@@ -263,6 +263,9 @@ static void _ILPrivateThreadDestroy(ILThread *thread)
        _ILSemaphoreDestroy(&(thread->suspendAck));
        _ILSemaphoreDestroy(&(thread->resumeAck));
        _ILWakeupQueueDestroy(&(thread->joinQueue));
+#ifdef IL_THREAD_DEBUG
+       fprintf(stderr, "ILThread destroyed: [%p]\n", thread);
+#endif /* IL_THREAD_DEBUG */
        ILFree(thread);
 }
 
@@ -421,6 +424,10 @@ ILThread *ILThreadCreate(ILThreadStartFunc startFunc, void 
*startArg)
        /* Make sure everything setup is seen by all threads. */
        ILInterlockedMemoryBarrier();
 
+#ifdef IL_THREAD_DEBUG
+       fprintf(stderr, "ILThread created: [%p]\n", thread);
+#endif /* IL_THREAD_DEBUG */
+
        return thread;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog           |   13 +++++++++
 engine/heap.c       |   19 +++++++++++-
 include/il_thread.h |   73 ++++++++++++++++++++++++++++++++++++++++++++++++-
 support/thr_defs.h  |   75 +-------------------------------------------------
 support/thread.c    |    7 +++++
 5 files changed, 111 insertions(+), 76 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]