| 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: | 41A483FB.9070106@samurai.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| 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.)
-Neil
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Neil Conway | 2004-11-24 13:02:10 | Re: -V, --version -- deprecated? |
| Previous Message | Bruce Momjian | 2004-11-24 12:34:26 | Re: lwlocks and starvation |