Index: src/backend/storage/lmgr/lwlock.c =================================================================== RCS file: /home/jjanes/pgrepo/pgsql/src/backend/storage/lmgr/lwlock.c,v retrieving revision 1.53 diff -c -r1.53 lwlock.c *** src/backend/storage/lmgr/lwlock.c 1 Jan 2009 17:23:48 -0000 1.53 --- src/backend/storage/lmgr/lwlock.c 28 Aug 2009 21:29:41 -0000 *************** *** 308,315 **** * * Side effect: cancel/die interrupts are held off until lock release. */ void ! LWLockAcquire(LWLockId lockid, LWLockMode mode) { volatile LWLock *lock = &(LWLockArray[lockid].lock); PGPROC *proc = MyProc; --- 308,317 ---- * * Side effect: cancel/die interrupts are held off until lock release. */ + + /* put yourself at the head of the queue, instead of the end, to acquire the lock*/ void ! LWLockAcquire_head(LWLockId lockid, LWLockMode mode) { volatile LWLock *lock = &(LWLockArray[lockid].lock); PGPROC *proc = MyProc; *************** *** 420,431 **** proc->lwWaiting = true; proc->lwExclusive = (mode == LW_EXCLUSIVE); ! proc->lwWaitLink = NULL; ! if (lock->head == NULL) ! lock->head = proc; ! else ! lock->tail->lwWaitLink = proc; ! lock->tail = proc; /* Can release the mutex now */ SpinLockRelease(&lock->mutex); --- 422,430 ---- proc->lwWaiting = true; proc->lwExclusive = (mode == LW_EXCLUSIVE); ! proc->lwWaitLink = lock->head; ! if (lock->head == NULL) { lock->tail=proc; }; ! lock->head=proc; /* Can release the mutex now */ SpinLockRelease(&lock->mutex); *************** *** 442,448 **** * so that the lock manager or signal manager will see the received * signal when it next waits. */ ! LOG_LWDEBUG("LWLockAcquire", lockid, "waiting"); #ifdef LWLOCK_STATS block_counts[lockid]++; --- 441,447 ---- * so that the lock manager or signal manager will see the received * signal when it next waits. */ ! LOG_LWDEBUG("LWLockAcquire_head", lockid, "waiting"); #ifdef LWLOCK_STATS block_counts[lockid]++;