15
15
* Portions Copyright (c) 1994, Regents of the University of California
16
16
*
17
17
* IDENTIFICATION
18
- * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.4 2001/12/10 21:13:50 tgl Exp $
18
+ * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.5 2001/12/28 23:26:04 tgl Exp $
19
19
*
20
20
*-------------------------------------------------------------------------
21
21
*/
@@ -64,16 +64,25 @@ static LWLockId held_lwlocks[MAX_SIMUL_LWLOCKS];
64
64
bool Trace_lwlocks = false;
65
65
66
66
inline static void
67
- PRINT_LWDEBUG (const char * where ,LWLockId lockid ,const LWLock * lock )
67
+ PRINT_LWDEBUG (const char * where ,LWLockId lockid ,const volatile LWLock * lock )
68
68
{
69
69
if (Trace_lwlocks )
70
70
elog (DEBUG ,"%s(%d): excl %d shared %d head %p" ,
71
71
where , (int )lockid ,
72
72
(int )lock -> exclusive ,lock -> shared ,lock -> head );
73
73
}
74
74
75
+ inline static void
76
+ LOG_LWDEBUG (const char * where ,LWLockId lockid ,const char * msg )
77
+ {
78
+ if (Trace_lwlocks )
79
+ elog (DEBUG ,"%s(%d): %s" ,
80
+ where , (int )lockid ,msg );
81
+ }
82
+
75
83
#else /* not LOCK_DEBUG */
76
84
#define PRINT_LWDEBUG (a ,b ,c )
85
+ #define LOG_LWDEBUG (a ,b ,c )
77
86
#endif /* LOCK_DEBUG */
78
87
79
88
@@ -265,6 +274,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
265
274
* received, so that the lock manager or signal manager will see
266
275
* the received signal when it next waits.
267
276
*/
277
+ LOG_LWDEBUG ("LWLockAcquire" ,lockid ,"waiting" );
278
+
268
279
for (;;)
269
280
{
270
281
/* "false" means cannot accept cancel/die interrupt here. */
@@ -274,6 +285,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
274
285
extraWaits ++ ;
275
286
}
276
287
288
+ LOG_LWDEBUG ("LWLockAcquire" ,lockid ,"awakened" );
289
+
277
290
/*
278
291
* The awakener already updated the lock struct's state, so we
279
292
* don't need to do anything more to it. Just need to fix the
@@ -352,6 +365,7 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
352
365
{
353
366
/* Failed to get lock, so release interrupt holdoff */
354
367
RESUME_INTERRUPTS ();
368
+ LOG_LWDEBUG ("LWLockConditionalAcquire" ,lockid ,"failed" );
355
369
}
356
370
else
357
371
{
@@ -448,6 +462,7 @@ LWLockRelease(LWLockId lockid)
448
462
*/
449
463
while (head != NULL )
450
464
{
465
+ LOG_LWDEBUG ("LWLockRelease" ,lockid ,"release waiter" );
451
466
proc = head ;
452
467
head = proc -> lwWaitLink ;
453
468
proc -> lwWaitLink = NULL ;