Memory management: Difference between revisions

no edit summary
[unchecked revision][unchecked revision]
No edit summary
 
(23 intermediate revisions by 15 users not shown)
Line 1:
'''Memory management''' is a critical part of any operating system [[Kernels|kernel]]. Providing a quick way for programs to allocate and free memory on a regular basis is a major responsibility of the kernel. There are many implementations for [[Page_Frame_Allocation|allocating physical memory]] including bitmaps, buddy allocation and using tree structures or queues/stacks.
 
''For an overview of memory allocation models, and methods of allocating memory, see [[Program Memory Allocation Types]]. If you are looking for heap type memory management, which is the allocation of smaller chunks of memory not on large boundaries then see the [[Heap|Heap]] page. A heap is commonly implemented (in the popular way of thinking) not only in the kernel, but also in applications - in the form of a standard library. For a discussion of automatic memory management methods, see [[Garbage Collection]].''
 
==Address Spaces==
Many platforms, including x86, use a memory management unit ([[MMU]]) to handle translation between the virtual and physical address spaces. Some architectures have the MMU built-in, while others have a separate chip. Having multiple address spaces allows each task to have its own memory space to work in. In modern systems this is a major part of memory protection. Keeping processes' memory spaces separate allows them to run without causing problems in another process's memory space.
 
===Physical Address Space===
The physical address space is the direct memory address used to access a real location in RAM. The addresses used in this space are the bit patterns used to identify a memory location on the address bus.
 
In this memory model, every executable or library must either use [[PIC]] (position-independent code), or come with relocation tables so jump and branch targets can be adjusted by the loader.
 
The AmigaOS used this memory model, in absence of a [[MMU]] in early 680x0 CPUs. It is most efficient, but it does not allow for protecting processes from each other, thus it is considered obsolete in today's desktop operating systems. It is also prone to memory fragmentation; certain embedded systems still use it, however.
 
===Virtual Address Space===
The advent of [[MMU]]s (Memory Management Units) allowedallows tovirtual play tricksaddresses to thebe addressingused. A virtual address couldcan be mapped to any physical address. It wasis possible to provide each executable with its own address space, so that memory always starts at 0x0000 0000. This relieves the executable loader of some relocation work, and solves the memory fragmentation problem - you no longer need physically continuous blocks of memory. And since the kernel is in control of the virtual-to-physical mapping, processes cannot access each other's memory unless allowed to do so by the kernel.
 
 
==Memory Translation Systems==
Line 20 ⟶ 21:
===Segmentation===
{{Main|Segmentation}}
Segmentation is not commonly available in mainstream systems except for the x86. In protected mode this method involves separating each area of memory for a process into units. This is handled by the segment [[RegisterCPU Registers x86#Segment Registers|segment registers]]: '''CS, DS, SS, ES, FS, GS''' (CodeSegment, DataSegment, StackSegment, the rest are ExtraSegments).
 
===Paging===
{{Main|Paging}}
 
Having an individual virtual-to-physical mapping for each address is of course ineffective. The traditional approach to virtual memory is to split up the available physical memory into chunks (pages), and to map virtual to physical addresses ''page-wise''. This task is largely handled by the [[MMU]], so the performance impact is low, and generally accepted as an appropriate price to pay for memory protection.
 
Line 44 ⟶ 45:
</blockquote>
 
==RelatedSee ArticlesAlso==
 
*[[Quick And Dirty Heap Algorithm]]
===Articles===
*[[Detecting Memory (x86)]]
*[[Garbage collection]]
*[[Memory Allocation]]
*[[Page Frame Allocation]]
*[[Writing a memory manager]] - a tutorial
*[[wikipedia:Memory segment|Memory Segments]] - Wikipedia article on segmentation
*[[Brendan's Memory Management Guide]]
*[[wikipedia:Paging|Paging]] - Wikipedia article on paging
*[[wikipedia:Memory management unit|MMU]] - Wikipedia article on Memory Management Units
 
==Related =Threads===
*[[topic:12307|Paging Mechanisms]]
*[[topic:12022|Paging Concepts (by Brendan)]]
*[[topic:22661|Paging Explained (by Creature)]]
 
===External Links===
*[http://www.osdever.net/tutorials.php?cat=6&sort=1 Memory Management Articles] - Bona Fide OS Development Articles on Memory Management
*[http://linux-mm.org/ LinuxMM] - A wiki documenting memory management projects and development
*[http://www.intel.com/products/processor/manuals/ Intel Systems Programming Documentation] Chapters 3 & 4 of Volume 3A
*[http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_739_7044,00.html AMD Systems Programming Documentation] Chapters 3 & 4 of Volume 2
*[http://www.intel.com/products/processor/manuals/ Intel Systems Programming Documentation] Chapters 3 & 4 of Volume 3A
*[http://linux-mm.org/ LinuxMM] - A wiki documenting memory management projects and development
*[http://www.osdever.net/tutorials.php?cat=6&sort=1/index#Memory-Management Memory Management Articles] - Bona Fide OS Development ArticlesTutorials on Memory Management
*[[wikipedia:Memory segmentmanagement | Memory Segmentsmanagement]] -on Wikipedia article on segmentation.
*[http://duartes.org/gustavo/blog/post/motherboard-chipsets-memory-map Jun 2008: Motherboard Chipsets and the Memory Map] by Gustavo Duarte
*[http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory Jan 2009: Anatomy of a Program in Memory] by Gustavo Duarte
 
[[Category:Memory management]]
[[Category:Physical Memory]]
[[Category:Virtual Memory]]
[[de:Speicherverwaltung]]
Anonymous user