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

Steve D'Aprano steve+python at pearwood.info
Fri Oct 13 21:22:32 EDT 2017


On Sat, 14 Oct 2017 01:51 am, Chris Angelico wrote:

> 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. 

So... not actually read-only then?

You have the program loader writing to it, repeatedly, every time you load a
program. And even the unprivileged program itself can write to it, if it
knows the correct incantation to use. So its more like Read/Write Memory, or
as we normally call it, memory.

You know, an awful lot of confusion could have been avoided if people had
referred to write-protected memory as write-protected rather than read-only.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list