Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Most OSes today do that "transparently" with virtual memory, but usually with a coarse granularity (e.g. 4k). A page table is just a translation of "pointers" to "memory addresses"; the OS can rearrange physical memory as it sees fit without the program having to update its pointers.

In OSes without virtual memory, one option is to do the same non-transparently: instead of returning pointers, malloc and friends work with "pointers to pointers" (called handles), so there is one extra level of indirection, and now the OS is free to rearrange this 2nd level as it sees fit. Whenever a program wants to read/write the data behind a handle, it must dereference the handle to get to the real pointer, but it also must let the OS know that it is currently using the real pointer -- this is to avoid the OS moving it around. This is usually called "locking/unlocking" the handle.

Some classic examples are Windows 3.x, Mac OS (toolbox), PalmOS, etc.

https://en.wikipedia.org/wiki/Classic_Mac_OS_memory_manageme...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: