20 ms·
> Why do we even have linear physical and virtual addresses in the first place, when pretty much everything today is object-oriented? Simple: we don't want som
by kazinator 4y ago
> Why do we even have linear physical and virtual addresses in the first place, when pretty much everything today is object-oriented?
Simple: we don't want some low level kernel memory management dictating what constitutes an "object".
Everything isn't object-oriented. E.g. large arrays, memory-mapped files, including executables and libraries.
Linear memory sucks, but every other organization sucks more.
Segmented has been done; the benefit-to-clunk ratio was negligible.
- MarkSweep 4y agoThe benefit-to-thunk ratio was not great either. ( one reference to thunks involving segmented memory: https://devblogs.microsoft.com/oldnewthing/20080207-00/?p=23533 https://devblogs.microsoft.com/oldnewthing/20080207-00/?p=23... )
- kazinator 4y agoReal segmentation would have solved the problem described in the article. Under virtual memory segments like on the 80386 (and mainframes before that), you can physically relocate a segment and while adjusting its descriptor so that the addressing doesn't change. The problem was mainly caused by having no MMU, so moving around objects in order to save space required adjusting pointers. Today, a copying garbage collector will do the same thing; rewrite all the links among the moved objects. You'd have similar hacks on Apple Macintoshes, with their MC68K processors and flat space, like doubly indirected objeccts managed by "handles" and whatnot.
- StillBored 4y agoThe 386 segmentation system exists above the paging portion of the MMU, so it is possible to move them around without physically copying memory (or adjusting the segment+offset). Here is a somewhat reasonable diagram of how it all works https://stackoverflow.com/questions/4039325/assembly-segmented-model-32bit-memory-limit https://stackoverflow.com/questions/4039325/assembly-segment... (although i'm probably agreeing with you)
- Stratoscope 4y agoIt's fun to see that old article again. (I wrote the FixDS program Raymond mentions at the end.) One pain point in 16-bit Windows programming was that you had to do two special things for any callback function in your application: EXPORT the function in your .DEF file, and call MakeProcInstance() on your callback function to get an "instance thunk". FixDS made a simple patch to the compiled function prologs that rendered all of this unnecessary. You could just use your callback function directly, like we expect today.
- 323 4y agoYet in practice the stack on x64 is separate from the heap, GPU memory is general is separate from system memory, and even inside the GPU you have at least a 3 level segmented memory hierarchy.
- gary_0 4y agoEven in C-land, you're technically not supposed to fabricate arbitrary heap pointers, you're supposed to offset something you get from malloc(). The Standard says (if memory serves) that only pointers from the beginning of a malloc() to 1-past-the-end have defined behavior (when it comes to the heap). Of course, there are probably lots of in-practice exceptions when it comes to embedded, kernel code, mmap() shenanigans, etc.
- e63f67dd-065b 4y agoOh boy, welcome to the exciting world of C pointer provenance :) What you just described is what compiler people call pointer provenance, where each pointer has, in addition to the address, a second piece of info attached to it that describes all the places to which the pointer can point. This is an extremely simplified and probably incorrect view of https://open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1434r0.html https://open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1434r0.... This is complicated because nobody agrees on what the correct behaviour should be, and we have mountains of legacy codebases that all rely on something slightly different when pointers get converted to ints and back.
- bawolff 4y agoPerhaps im misunderstanding, but it seems like you are using object-oriented in a different sense than the article does
- MaxBarraclough 4y agoI'm reminded of an old comment that expressed a similar sentiment: we've discovered over time that OS Kernels aren't the place for Grand Abstractions. [0] https://news.ycombinator.com/item?id=9807777 https://news.ycombinator.com/item?id=9807777