You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 04_Memory_Management/04_Virtual_Memory_Manager.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,6 +280,6 @@ We've looked a basic VMM implementation, and discussed some advanced concepts to
280
280
281
281
As mentioned above all the memory accessed is virtual memory at this point, so unless there is a specific reason to interact with the PMM it can be best to deal with the VMM instead. Then let the VMM manage the physical memory it may or may not need.
282
282
283
-
Of course there will be cases where this is not possible, and there are valid reasons to allocate physical memory directory (DMA buffers for device drivers, for example), but for the most part the VMM should be the interface to interact with memory.
283
+
Of course there will be cases where this is not possible, and there are valid reasons to allocate physical memory directly (DMA buffers for device drivers, for example), but for the most part the VMM should be the interface to interact with memory.
284
284
285
285
This VMM design that was explained here is based on a stripped-down version of the Solaris VMM. It's very well understood and there is plenty of more in depth material out there if interested in exploring further. The original authors have also published several papers on the topic.
Copy file name to clipboardExpand all lines: 04_Memory_Management/05_Heap_Allocation.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ We'll focus on three things: allocating memory (`alloc()`), freeing memory (`fre
9
9
10
10
### To Avoid Confusion
11
11
12
-
The term 'heap' has a few meanings, and if coming from a computer science course the first though might be the data structure (specialized tree). That can be used to implement a heap allocator (hence the name), but it's not what we're talking about here.
12
+
The term 'heap' has a few meanings, and if coming from a computer science course the first thought might be the data structure (specialized tree). That can be used to implement a heap allocator (hence the name), but it's not what we're talking about here.
13
13
14
14
This term when used in a memory management/osdev environment has a different meaning, and it usually refers to the code where memory is _dynamically allocated_ (`malloc()` and friends).
15
15
@@ -24,7 +24,7 @@ If some of these terms need more explanation, they have chapters of their own to
24
24
25
25
With the above assumptions, what happens under the hood when we want to allocate some memory from the heap?
26
26
27
-
* The heap searches for a suitable address. If one is found returns that address is returned and the algorithm stops there. If it can't find any it will ask the VMM for more space.
27
+
* The heap searches for a suitable address. If one is found that address is returned and the algorithm stops there. If it can't find any it will ask the VMM for more space.
28
28
* The VMM will receive the heap's request and ask the PMM a suitable physical page to be allocated to fulfill the heap's request.
29
29
* The PMM search for a suitable physical page to fulfill the VMM's request, returning that address to the VMM.
30
30
* Once the VMM has the physical memory, that memory is mapped into the program's virtual address space, at the address the heap requested (usually at the end).
@@ -49,7 +49,7 @@ So let's get started with describing the allocation algorithm.
49
49
50
50
*Authors note: In the following examples we will use `uint8_t` for all the pointers, but in a real scenario it will be better to use a bigger size for the variable keeping track of the allocated region sizes (so we're not limited to 255 bytes).*
51
51
52
-
The easiest way to start with creating our allocator is to ask: "What do a heap allocator do?".
52
+
The easiest way to start with creating our allocator is to ask: "What does a heap allocator do?".
53
53
54
54
Well the answer is, as we already know: it allocates memory, specifically in bytes. The bytes part is important, because as kernel developers we're probably used to dealing with pages and page-sized things. If the program asks for _X_ bytes, the allocator will return an address pointing to an area of memory that is at least _X_ bytes. The VMM is allocating memory, but the biggest difference is that the Heap is allocating bytes, while the VMM is allocating Pages.
0 commit comments