[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog support/pt_defs.c support/pt_def...
From: |
Klaus Treichel |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog support/pt_defs.c support/pt_def... |
Date: |
Mon, 04 Sep 2006 18:07:30 +0000 |
CVSROOT: /cvsroot/dotgnu-pnet
Module name: pnet
Changes by: Klaus Treichel <ktreichel> 06/09/04 18:07:30
Modified files:
. : ChangeLog
support : pt_defs.c pt_defs.h
engine : lib_gc.c
Log message:
2006-09-04 Klaus treichel <address@hidden>
* support/pt_defs.c: Add a default mutex attribute to make sure
that fast
(deadlocking) mutexes are used. Initialize this mutex attribute
during
initialization of threading.
* support/pt_defs.h: Add an extern declaration of the new mutex
attribute
and replace the 0 mutex attribute in pthread_mutex_init with a
reference
to the new created attribute.
* engine/lib_gc.c: Add a separate mutex in the gc handletable to
syncronize the access to this table instead of using the
process->lock
mutex (which caused deadlocks if finalizers are invoked).
We use the process->lock only for the creation of the table and
disable
/enable finalizers at this point.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3358&r2=1.3359
http://cvs.savannah.gnu.org/viewcvs/pnet/support/pt_defs.c?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnet/support/pt_defs.h?cvsroot=dotgnu-pnet&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/lib_gc.c?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3358
retrieving revision 1.3359
diff -u -b -r1.3358 -r1.3359
--- ChangeLog 4 Sep 2006 10:11:30 -0000 1.3358
+++ ChangeLog 4 Sep 2006 18:07:30 -0000 1.3359
@@ -1,3 +1,19 @@
+2006-09-04 Klaus treichel <address@hidden>
+
+ * support/pt_defs.c: Add a default mutex attribute to make sure that
fast
+ (deadlocking) mutexes are used. Initialize this mutex attribute during
+ initialization of threading.
+
+ * support/pt_defs.h: Add an extern declaration of the new mutex
attribute
+ and replace the 0 mutex attribute in pthread_mutex_init with a reference
+ to the new created attribute.
+
+ * engine/lib_gc.c: Add a separate mutex in the gc handletable to
+ syncronize the access to this table instead of using the process->lock
+ mutex (which caused deadlocks if finalizers are invoked).
+ We use the process->lock only for the creation of the table and disable
+ /enable finalizers at this point.
+
2006-09-04 Radek Polak <address@hidden>
* engine/debugger.c: reformat with tabs set to 4, implemented
Index: support/pt_defs.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/pt_defs.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- support/pt_defs.c 10 Oct 2005 20:03:15 -0000 1.8
+++ support/pt_defs.c 4 Sep 2006 18:07:30 -0000 1.9
@@ -46,6 +46,11 @@
pthread_key_t _ILThreadObjectKey;
/*
+ * Default mutex attribute.
+ */
+pthread_mutexattr_t _ILMutexAttr;
+
+/*
* Suspend until we receive IL_SIG_RESUME from another thread
* in this process.
*
@@ -158,6 +163,12 @@
/* We need a thread-specific key for storing thread objects */
pthread_key_create(&_ILThreadObjectKey, (void (*)(void *))0);
+ /* Initialize the mutexattr used on this system. */
+ pthread_mutexattr_init(&_ILMutexAttr);
+#ifdef PTHREAD_MUTEX_NORMAL
+ pthread_mutexattr_settype(&_ILMutexAttr, PTHREAD_MUTEX_NORMAL);
+#endif
+
/* Block the IL_SIG_RESUME signal in the current thread.
It will be unblocked by "SuspendUntilResumed" */
sigemptyset(&set);
Index: support/pt_defs.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/support/pt_defs.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- support/pt_defs.h 1 Nov 2005 19:14:19 -0000 1.9
+++ support/pt_defs.h 4 Sep 2006 18:07:30 -0000 1.10
@@ -156,8 +156,9 @@
* Primitive mutex operations. Note: the "Lock" and "Unlock"
* operations are not "suspend-safe".
*/
+extern pthread_mutexattr_t _ILMutexAttr;
#define _ILMutexCreate(mutex) \
- (pthread_mutex_init((mutex), (pthread_mutexattr_t *)0))
+ (pthread_mutex_init((mutex), &_ILMutexAttr))
#define _ILMutexDestroy(mutex) \
(pthread_mutex_destroy((mutex)))
#define _ILMutexLockUnsafe(mutex) \
Index: engine/lib_gc.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_gc.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- engine/lib_gc.c 18 Jul 2006 05:20:44 -0000 1.10
+++ engine/lib_gc.c 4 Sep 2006 18:07:30 -0000 1.11
@@ -119,6 +119,9 @@
*/
typedef struct _tagILGCHandleTable
{
+ /* Lock to serialize access to this object */
+ ILMutex *lock;
+
void **regularHandles;
ILInt32 numRegularHandles;
void **weakHandles;
@@ -126,17 +129,53 @@
} ILGCHandleTable;
+static void _ILGCHandleTableInit(ILGCHandleTable *table)
+{
+ /* Initialize all members even if that might be not needed. */
+ table->regularHandles = 0;
+ table->numRegularHandles = 0;
+ table->weakHandles = 0;
+ table->numWeakHandles = 0;
+
+ /* Initialize the object lock */
+ table->lock = ILMutexCreate();
+}
+
/*
* Get the GC handle table and lock it down.
*/
static ILGCHandleTable *GetGCHandleTable(ILExecThread *_thread)
{
ILExecProcess *process = _thread->process;
+ if(!(process->gcHandles))
+ {
ILMutexLock(process->lock);
+ /* Check again because of race conditions. */
if(!(process->gcHandles))
{
+ /* Disable finalizers here because we hold the process
lock.
+ * Otherwise we might get a deadlock if finalizers are
invoked
+ * the first time and the finalizer thread is created.
+ */
+ ILGCDisableFinalizers(-1);
process->gcHandles = (ILGCHandleTable *)
ILGCAllocPersistent(sizeof(ILGCHandleTable));
+ ILGCEnableFinalizers();
+ if(process->gcHandles)
+ {
+ _ILGCHandleTableInit(process->gcHandles);
+ ILMutexLock(process->gcHandles->lock);
+ }
+ }
+ else
+ {
+ ILMutexLock(process->gcHandles->lock);
+ }
+ ILMutexUnlock(process->lock);
+ }
+ else
+ {
+ ILMutexLock(process->gcHandles->lock);
}
return process->gcHandles;
}
@@ -144,9 +183,9 @@
/*
* Unlock the GC handle table.
*/
-static void UnlockGCHandleTable(ILExecThread *_thread)
+static void UnlockGCHandleTable(ILGCHandleTable *table)
{
- ILMutexUnlock(_thread->process->lock);
+ ILMutexUnlock(table->lock);
}
ILNativeInt _IL_GCHandle_GCAddrOfPinnedObject(ILExecThread *_thread,
@@ -178,10 +217,9 @@
}
}
}
- }
-
/* Unlock the handle table */
- UnlockGCHandleTable(_thread);
+ UnlockGCHandleTable(table);
+ }
/* None of the objects in our implementation move about
memory, so the object pointer is the pinned address */
@@ -232,9 +270,8 @@
if((table->numWeakHandles & 7) == 0)
{
/* Extend the size of the weak handle
table */
- /*
- *****: for weak refs, do not use
AllocPersistent
- newArray = (void **)ILGCAllocPersistent
+ /* for weak refs, do use AllocAtomic so
that the ref will
+ * not be scanned.by the gc during
collection.
*/
newArray = (void **)ILGCAllocAtomic
((table->numWeakHandles + 8) *
sizeof(void *));
@@ -251,12 +288,9 @@
if(table->weakHandles[index] !=
(void
*)(ILNativeInt)(-1))
{
- /* *****:
-
ILGCUnregisterWeak(&(table->weakHandles[index]));
-
ILGCRegisterWeak(&(newArray[index]));
+ /* use
RegisterGeneralWeak to monitor
+ * disappearing
links
*/
-
- // use
RegisterGeneralWeak to monitor disappearing links
if( 0 !=
table->weakHandles[index] ) {
ILGCUnregisterWeak(&(table->weakHandles[index]));
}
@@ -270,8 +304,6 @@
table->weakHandles = newArray;
}
table->weakHandles[table->numWeakHandles] = ptr;
- // *****:
- //
ILGCRegisterWeak(&(table->weakHandles[table->numWeakHandles]));
if( 0 !=
table->weakHandles[table->numWeakHandles] ) {
ILGCRegisterGeneralWeak(&(table->weakHandles[table->numWeakHandles]),
table->weakHandles[table->numWeakHandles] );
@@ -315,10 +347,10 @@
}
break;
}
+ /* Unlock the GC handle table and return */
+ UnlockGCHandleTable(table);
}
- /* Unlock the GC handle table and return */
- UnlockGCHandleTable(_thread);
return handle;
}
@@ -359,10 +391,9 @@
}
break;
}
- }
-
/* Unlock the GC handle table and return */
- UnlockGCHandleTable(_thread);
+ UnlockGCHandleTable(table);
+ }
}
ILBool _IL_GCHandle_GCValidate(ILExecThread *_thread, ILInt32 handle)
@@ -391,10 +422,10 @@
}
break;
}
+ /* Unlock the handle table and return */
+ UnlockGCHandleTable(table);
}
- /* Unlock the handle table and return */
- UnlockGCHandleTable(_thread);
return valid;
}
@@ -440,10 +471,10 @@
{
object = GetObjectFromGcBase(ptr);
}
+ /* Unlock the handle table and return */
+ UnlockGCHandleTable(table);
}
- /* Unlock the handle table and return */
- UnlockGCHandleTable(_thread);
return object;
}
@@ -478,18 +509,16 @@
if(table->weakHandles[index - 1] !=
(void
*)(ILNativeInt)(-1))
{
- /* *****:
- unregister old Target and
Register new Ttarget
- */
-
- if( 0 !=
table->weakHandles[index - 1] ) {
+ /* unregister old Target and
Register new target */
+ if( 0 !=
table->weakHandles[index - 1] )
+ {
ILGCUnregisterWeak(&(table->weakHandles[index-1]));
}
table->weakHandles[index - 1] =
ptr;
- // *****:
- if( 0 != ptr ) {
+ if( 0 != ptr )
+ {
ILGCRegisterGeneralWeak(&(table->weakHandles[index-1]),
table->weakHandles[index-1] );
}
}
@@ -511,10 +540,9 @@
}
break;
}
- }
-
/* Unlock the handle table and return */
- UnlockGCHandleTable(_thread);
+ UnlockGCHandleTable(table);
+ }
}
void _ILGCHandleTableFree(ILGCHandleTable *table)
@@ -530,9 +558,13 @@
{
ILGCUnregisterWeak(&(table->weakHandles[index]));
}
- ILGCFreePersistent(table->weakHandles);
}
- ILGCFreePersistent(table);
+
+ if(table->lock)
+ {
+ /* Destroy the object lock */
+ ILMutexDestroy(table->lock);
+ }
}
#endif /* IL_CONFIG_RUNTIME_INFRA */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog support/pt_defs.c support/pt_def...,
Klaus Treichel <=