Lies in education [was Re: The "loop and a half"]

Chris Angelico rosuav at gmail.com
Fri Oct 13 10:51:42 EDT 2017


On Sat, Oct 14, 2017 at 1:32 AM, Steve D'Aprano
<steve+python at pearwood.info> wrote:
> It seems to me that you're not talking about ROM at all, but ordinary RAM.
> Then what do you mean by "read only"? A block of memory with a flag that
> says "unprivileged processes are prohibited from writing here"?
>
> (That's also not a rhetorical question.)

When I first learned about Protected Mode (as defined by the Intel
80386 and used in OS/2), there was a real concept of read-only RAM.
The program loader would fetch up the executable file (data on the
disk) and construct its segments: code, data, and BSS/stack. The data,
BSS, and stack all end up as a single segment (data is what comes
straight off the disk, BSS is all zeroes initially, and stack is
uninitialized initially, but ultimately they're all read/write), and
code is in its own segment. When control is handed to the new process,
its segment table grants it read/write access to the data/stack
segment, but read-only access to its code segment. Within that
process, the code really truly is read-only, unless some magic is
done. And yes, since it is fully readable, constant data CAN be
included alongside actual executable code, but it's never going to be
mutable in any way.

ChrisA



More information about the Python-list mailing list