Skip site navigation (1) Skip section navigation (2)

Re: lwlocks and starvation

From: Neil Conway <neilc(at)samurai(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lwlocks and starvation
Date: 2004-11-24 12:52:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Bruce Momjian wrote:
> I thought the new readers will sit after the writer in the FIFO queue so
> the writer will not starve.

AFAICS, that is not the case. See lwlock.c, circa line 264: in LW_SHARED 
mode, we check if "exclusive" is zero; if so, we acquire the lock 
(increment the shared lock count and do not block). And "exclusive" is 
set non-zero only when we _acquire_ a lock in exclusive mode, not when 
we add an exclusive waiter to the wait queue.

(Speaking of which, the "exclusive" field is declared as a "char"; I 
wonder if it wouldn't be more clear to declare it as "bool", and treat 
it as a boolean field. The storage/alignment requirements should be the 
same (bool is a typedef for char, at least a C compiler), but IMHO it 
would be more logical.)


In response to


pgsql-hackers by date

Next:From: Neil ConwayDate: 2004-11-24 13:02:10
Subject: Re: -V, --version -- deprecated?
Previous:From: Bruce MomjianDate: 2004-11-24 12:34:26
Subject: Re: lwlocks and starvation

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group