A Ksem question [Was: Re: changes to thread locking layer]
Patrick Tullmann
tullmann at cs.utah.edu
Tue Apr 11 16:36:09 PDT 2000
Alan L. Batongbacal wrote:
> Correct. I use ThreadState just because it deadlocks the fastest :)
Just to be clear: this test *always* locks up, right? You just have
trouble creating a deadlock that gdb can dump state about, right? Do
you know if it is always deadlocking in the same place?
I've attached a patch for locks.c that adds some more SLOWLOCK
debugging magic. Makes it a bit easier to read the trace... I
haven't looked too closely at the output generated by the
Kaffe unix-jthreads version, though.
If someone wants to check this in, here's a ChangeLog:
Patrick Tullmann <tullmann at cs.utah.edu>
* kaffe/kaffevm/locks.c: Add a bunch more SLOWLOCKS debugging
printfs.
-Pat
----- ----- ---- --- --- -- - - - - -
Pat Tullmann tullmann at cs.utah.edu
That which does not kill you just didn't try hard enough.
Index: kaffe/kaffevm/locks.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/locks.c,v
retrieving revision 1.34
diff -u -u -r1.34 locks.c
--- locks.c 1999/12/10 07:49:04 1.34
+++ locks.c 2000/04/11 23:33:14
@@ -1,5 +1,5 @@
/*
- * fastlocks.c
+ * locks.c
* Manage locking system
*
* Copyright (c) 1996-1999
@@ -99,8 +99,8 @@
int i;
DBG(SLOWLOCKS,
- dprintf("getHeavyLock(**lkp=%p, *lk=%p)\n",
- lkp, *lkp);
+ dprintf(" getHeavyLock(**lkp=%p, *lk=%p, th=%p)\n",
+ lkp, *lkp, jthread_current());
)
timeout = 1;
@@ -121,6 +121,9 @@
/* If bottom bit is set, strip off and use pointer as pointer to heavy lock */
if ((((uintp)old) & 1) == 1) {
+DBG(SLOWLOCKS,
+ dprintf(" got cached lock\n");
+)
lk = (iLock*)(((uintp)old) & (uintp)-2);
}
else {
@@ -133,7 +136,7 @@
}
}
DBG(SLOWLOCKS,
- dprintf(" got %s lock\n",
+ dprintf(" got %s lock\n",
(lk == 0) ? "new" : "special");
)
if (lk == 0) {
@@ -158,8 +161,8 @@
assert(*lkp == LOCKINPROGRESS);
DBG(SLOWLOCKS,
- dprintf("putHeavyLock(**lkp=%p, *lk=%p)\n",
- lkp, lk);
+ dprintf(" putHeavyLock(**lkp=%p, *lk=%p, th=%p)\n",
+ lkp, lk, jthread_current());
)
if (lk == LOCKFREE) {
@@ -181,8 +184,8 @@
Hjava_lang_Thread* tid;
DBG(SLOWLOCKS,
- printf("slowLockMutex(**lkp=%p, where=%p)\n",
- lkp, where);
+ dprintf("slowLockMutex(**lkp=%p, where=%p, th=%p)\n",
+ lkp, where, jthread_current());
)
for (;;) {
@@ -223,8 +226,8 @@
int i;
DBG(SLOWLOCKS,
- printf("slowUnlockMutex(**lkp=%p, where=%p)\n",
- lkp, where);
+ dprintf("slowUnlockMutex(**lkp=%p, where=%p, th=%p)\n",
+ lkp, where, jthread_current());
)
lk = getHeavyLock(lkp);
@@ -277,6 +280,11 @@
iLock* lk;
void* holder;
+DBG(SLOWLOCKS,
+ dprintf("slowUnlockMutexIfHeld(**lkp=%p, where=%p, th=%p)\n",
+ lkp, where, jthread_current());
+)
+
lk = getHeavyLock(lkp);
holder = lk->holder;
putHeavyLock(lkp, lk);
@@ -292,6 +300,11 @@
iLock* lk;
void* holder;
+DBG(SLOWLOCKS,
+ dprintf("_releaseLock(**lkp=%p, th=%p)\n",
+ lkp, jthread_current());
+)
+
lk = getHeavyLock(lkp);
holder = lk->holder;
@@ -319,6 +332,11 @@
Hjava_lang_Thread** ptr;
jboolean r;
+DBG(SLOWLOCKS,
+ dprintf("_waitCond(**lkp=%p, timeout=%ld, th=%p)\n",
+ lkp, (long)timeout, jthread_current());
+)
+
lk = getHeavyLock(lkp);
holder = lk->holder;
@@ -373,6 +391,11 @@
iLock* lk;
Hjava_lang_Thread* tid;
+DBG(SLOWLOCKS,
+ dprintf("_signalCond(**lkp=%p, th=%p)\n",
+ lkp, jthread_current());
+)
+
lk = getHeavyLock(lkp);
if (!jthread_on_current_stack(lk->holder)) {
@@ -396,6 +419,11 @@
{
iLock* lk;
Hjava_lang_Thread* tid;
+
+DBG(SLOWLOCKS,
+ dprintf("_broadcastCond(**lkp=%p, th=%p)\n",
+ lkp, jthread_current());
+)
lk = getHeavyLock(lkp);
More information about the kaffe
mailing list