|
1 | 1 | #ifndef SEGMENTS_H |
2 | 2 | #define SEGMENTS_H |
3 | 3 |
|
4 | | -/* |
5 | | - Heap-Level: |Metadata|Segment|guard|Segment|guard|Segment|...| # size = |
6 | | -2GB Segment-Level: |Metadata|guard|slot|slot|slot|...| # size = 4MB->(32MB*) |
7 | | -(this would mean that about 2048 segments couldfit inside of our heap at any |
8 | | -time which is almost a bit too much so what I will actualy do is set this value |
9 | | -higher meaning each segment is larger. if we use the same pointer access trick |
10 | | -as before and maintain our alignment then we should be able to access any given |
11 | | -page in constant time so it hsouldn't be that big of a deal that we have a |
12 | | -larger segment size. Thus set segment size to say 32MB?) Page-Level: |
13 | | -|Metadata|chunk|chunk|chunk|...|guard| # size : small=64KB, |
14 | | -med=512KB, large=4MiB ---> this means we can fit multiple large pages w/i a |
15 | | -segment, XL allocations will still be handled using MMAP. |
16 | | -
|
17 | | - Heap metadata: we should track how many segments are active, their types, |
18 | | -the location of the metadata corresponding to a given chunk so that we can |
19 | | -access it if it contains a size and space we need. |
20 | | -. |
21 | | - It contains information about the sizes that the pages w/i it support, a |
22 | | -bitmap that tracks the allocation status of the contained pages. This can be |
23 | | -found by querying the metadata of each page and checking if used == 0. Maybe |
24 | | -also track the status of the segment itself; any given segment could be |
25 | | -completely empty, active, or full. But we should probably make sure there is a |
26 | | -minimum number (1sm, 1md) active at all times. |
27 | | -
|
28 | | -
|
29 | | - I don't intend to implement any form of coalescing - much like partition |
30 | | -alloc, I will release memory to OS but keep the vmem reservation |
31 | | -
|
32 | | -*/ |
33 | | -// lets make sure our guard pages are the same size as the chunks so that we can |
34 | | -// handle indexing w/ offsets normally |
35 | | - |
36 | 4 | #include "types.h" |
37 | 5 | #include <cstdint> |
38 | 6 | #include <iostream> |
|
0 commit comments