Re: lwlocks and starvation

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: lwlocks and starvation
Дата
Msg-id 41A483FB.9070106@samurai.com
обсуждение исходный текст
Ответ на Re: lwlocks and starvation  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: lwlocks and starvation  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: lwlocks and starvation  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: lwlocks and starvation  (Simon Riggs <simon@2ndquadrant.com>)
Список 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.)

-Neil


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: lwlocks and starvation
Следующее
От: Neil Conway
Дата:
Сообщение: Re: -V, --version -- deprecated?