Global/Static function/variable slower to access?

This is a discussion on Global/Static function/variable slower to access? within the C++ Programming forums, part of the General Programming Boards category; Hey guys,
So I learned about the cpu and some real low level stuff recently and I have to ask, ...

On systems where stack space is dynamically mapped, the first time you access a local variable may result in a page fault, which would be exceedingly slow.

Likewise, an often accessed global variable may be "permanently" in cache.

But then again, on a paged virtual desktop OS, the whole thing could be being paged in and out of memory anyway.

The difference is minute (and could go one way or the other). And being so small, it's effect will be swamped by all sorts of other factors, some under your control (like using the optimisation flags), and some not under your control (like how many other processes are running on the machine).