Re: Strange Windows problem, lock_timeout test request - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Strange Windows problem, lock_timeout test request
Date
Msg-id 11304.1363585650@sss.pgh.pa.us
Whole thread Raw
In response to Re: Strange Windows problem, lock_timeout test request  (Boszormenyi Zoltan <zb@cybertec.at>)
Responses Re: Strange Windows problem, lock_timeout test request  (Boszormenyi Zoltan <zb@cybertec.at>)
List pgsql-hackers
Boszormenyi Zoltan <zb@cybertec.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



pgsql-hackers by date:

Previous
From: Boszormenyi Zoltan
Date:
Subject: Re: Strange Windows problem, lock_timeout test request
Next
From: Ian Pilcher
Date:
Subject: Re: Trust intermediate CA for client certificates