Guess read only RAM becomes… ROM? :D I have no clue either. Maybe there are protected areas in the memory no program has write access to, so it is read only from perspective of the application. Searching the web doesn’t help, because every link I clicked just explains the difference between ROM and RAM.
Hmm… when I think about Rust programming (which is true in C too probably), there are two types of locations our variables can assigned to: Stack and Heap. In example if you have a text string as a literal like “Version 1.0”, that string is located in the Stack memory, because it is unchanging. The Heap gets all those content that can vary and arbitrary long, but its slower. So the Stack content is much smaller, faster and basically read only RAM area (if I understand this correctly). Maybe that is it?
I’m drawing on some old memories here, so I could be mistaken, but I don’t think the stack is read only, not in C anyway or in the underlying machine code. If it is faster it has to do with greater overhead needed managing the larger heap and perhaps being more efficient to push and pop with small offsets to a local stack frame vs large absolute addresses.
I don’t mean the stack is read only (edit: yes I meant that in my previous reply, but got confused myself, I actually never thought the entire stack being read only, I was only thinking about those specific variables and literal strings, sorry for confusion), but certain variables holding values that are only used to read and not change. In example you cannot change literals, therefore they are read only values. In example if you have a program that prints “Hello Lemmy”, that string is a literal that cannot be altered, and it is found in the application itself, as part of the binary. That part maybe is marked as read only?
Right, a stack that was itself read-only would be hard to use! :^D
C definitely lets you modify the things in the stack. (Ah the fun of bugs where you accidentally overwrite other shit on the stack!) I don’t know Rust, but it would not surprise me if Rust only had immutable things on the stack.
No, its not only immutable things on the stack. I mean if you include a literal constant string such as “MIT LICENSE”, that is part of the compiled binary file. So it is unchangeable. Because you cannot change a literal, a “1” is always a “1” in the compiled binary file. And those are basically read only by their nature and loaded into the stack. I think or guess in C it is the same. Or any language for that matter.
Yeah wait how would you have read only RAM?
Loaded on boot for the OS I suppose?
Probably nice for running TV boxes off even less RAM than they’re already starved for lmao
Guess read only RAM becomes… ROM? :D I have no clue either. Maybe there are protected areas in the memory no program has write access to, so it is read only from perspective of the application. Searching the web doesn’t help, because every link I clicked just explains the difference between ROM and RAM.
Hmm… when I think about Rust programming (which is true in C too probably), there are two types of locations our variables can assigned to: Stack and Heap. In example if you have a text string as a literal like “Version 1.0”, that string is located in the Stack memory, because it is unchanging. The Heap gets all those content that can vary and arbitrary long, but its slower. So the Stack content is much smaller, faster and basically read only RAM area (if I understand this correctly). Maybe that is it?
I’m drawing on some old memories here, so I could be mistaken, but I don’t think the stack is read only, not in C anyway or in the underlying machine code. If it is faster it has to do with greater overhead needed managing the larger heap and perhaps being more efficient to push and pop with small offsets to a local stack frame vs large absolute addresses.
I don’t mean the stack is read only (edit: yes I meant that in my previous reply, but got confused myself, I actually never thought the entire stack being read only, I was only thinking about those specific variables and literal strings, sorry for confusion), but certain variables holding values that are only used to read and not change. In example you cannot change literals, therefore they are read only values. In example if you have a program that prints “Hello Lemmy”, that string is a literal that cannot be altered, and it is found in the application itself, as part of the binary. That part maybe is marked as read only?
Right, a stack that was itself read-only would be hard to use! :^D C definitely lets you modify the things in the stack. (Ah the fun of bugs where you accidentally overwrite other shit on the stack!) I don’t know Rust, but it would not surprise me if Rust only had immutable things on the stack.
No, its not only immutable things on the stack. I mean if you include a literal constant string such as “MIT LICENSE”, that is part of the compiled binary file. So it is unchangeable. Because you cannot change a literal, a “1” is always a “1” in the compiled binary file. And those are basically read only by their nature and loaded into the stack. I think or guess in C it is the same. Or any language for that matter.
I started to think I was hallucinating. I guess what I was thinking is this part https://en.wikipedia.org/wiki/Data_segment . There are read-only data segments too.