[M3devel] debugability of AtForkPrepare?
Jay K
jay.krell at cornell.edu
Tue Jan 11 09:06:58 CET 2011
?
This makes AtForkPrepare more debuggable, by sometimes indicating
mutexes by index instead of pointer. It doesn't otherwise change it.
Good/bad?
Index: ThreadPThread.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-libs/m3core/src/thread/PTHREAD/ThreadPThread.m3,v
retrieving revision 1.252
diff -u -w -r1.252 ThreadPThread.m3
--- ThreadPThread.m3 11 Jan 2011 05:13:59 -0000 1.252
+++ ThreadPThread.m3 11 Jan 2011 08:03:22 -0000
@@ -1250,23 +1250,26 @@
VAR locks := ARRAY [0..4] OF pthread_mutex_t
{ initMu, heapMu, activeMu, slotsMu, perfMu };
-PROCEDURE PThreadLockMutex(mutex: pthread_mutex_t; line: INTEGER) =
+PROCEDURE PThreadLockMutex(mutex: pthread_mutex_t;
+ line: INTEGER;
+ index: INTEGER := -1) =
BEGIN
- IF mutex # NIL THEN
+ IF index >= 0 THEN <*ASSERT mutex = NIL*> mutex := locks[index]; END;
+ IF mutex = NIL THEN RETURN; END;
WITH r = pthread_mutex_lock(mutex) DO
IF r # 0 THEN DieI(line, r) END;
END;
- END;
END PThreadLockMutex;
PROCEDURE PThreadUnlockMutex(mutex: pthread_mutex_t;
- line: INTEGER) =
+ line: INTEGER;
+ index: INTEGER := -1) =
BEGIN
- IF mutex # NIL THEN
+ IF index >= 0 THEN <*ASSERT mutex = NIL*> mutex := locks[index]; END;
+ IF mutex = NIL THEN RETURN; END;
WITH r = pthread_mutex_unlock(mutex) DO
IF r # 0 THEN DieI(line, r) END;
END;
- END;
END PThreadUnlockMutex;
PROCEDURE AtForkPrepare() =
@@ -1276,7 +1279,7 @@
BEGIN
Acquire(joinMu);
FOR i := FIRST(locks) TO LAST(locks) DO
- PThreadLockMutex(locks[i], ThisLine());
+ PThreadLockMutex(NIL, ThisLine(), i);
END;
(* Walk activations and lock all threads, conditions.
* NOTE: We have initMu, activeMu, so slots
@@ -1308,7 +1311,7 @@
act := act.next;
UNTIL act = me;
FOR i := LAST(locks) TO FIRST(locks) BY -1 DO
- PThreadUnlockMutex(locks[i], ThisLine());
+ PThreadUnlockMutex(NIL, ThisLine(), i);
END;
Release(joinMu);
END AtForkParent;
More information about the M3devel
mailing list