From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
Cc: | Stephen Frost <sfrost(at)snowman(dot)net>, Hari Babu <haribabu(dot)kommi(at)huawei(dot)com>, "'Craig Ringer'" <craig(at)2ndQuadrant(dot)com>, 'Hans-Jürgen Schönig' <hs(at)cybertec(dot)at>, "'Ants Aasma'" <ants(at)cybertec(dot)at>, "'PostgreSQL Hackers'" <pgsql-hackers(at)postgresql(dot)org>, "'Amit kapila'" <amit(dot)kapila(at)huawei(dot)com> |
Subject: | Re: Strange Windows problem, lock_timeout test request |
Date: | 2013-03-18 05:47:30 |
Message-ID: | 11304.1363585650@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
>> The volatile marking shouldn't even be necessary there.
>> The signal handler doesn't writes to it, only the main code.
Well, (a) that's not the case in the patch as committed, and (b) even if
it were true, the volatile marking is still *necessary*, because that's
what tells the compiler it can't optimize away changes to the variable,
say on the grounds of there being another store with no intervening
fetches in the main-line code. Without that, a compiler that had
aggressively inlined the smaller functions could well deduce that the
disable_alarm() assignment was useless.
> Also, since the the variable assignment doesn't depend on other code
> in the same function (or vice-versa) the compiler is still free to
> reorder it.
> Volatile is about not caching the variable in a CPU register since
> it's "volatile"...
I don't believe you understand what volatile is about at all. Go read
the C standard: it's about requiring objects' values to actually match
the nominal program-specified values at sequence points. A more
accurate heuristic is that volatile tells the compiler there may be
other forces reading or writing the variable besides the ones it can see
in the current function's source code, and so it can't drop or reorder
accesses to the variable.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Pilcher | 2013-03-18 06:27:55 | Re: Trust intermediate CA for client certificates |
Previous Message | Boszormenyi Zoltan | 2013-03-18 05:29:37 | Re: Strange Windows problem, lock_timeout test request |