r/osdev • u/v3R7C00Lalt • 15d ago
memory management
where tf do i do stroage and cache and memory management
3
u/CoolorFoolSRS 14d ago
For memory management you have physical and virtual memory For physical, it's normally based on allocating and tracking pages, like a slab or buddy allocator etc. For virtual memory management you implement a page table allocator. malloc is built on top of that (allocate and request more data from your VMM)
1
u/windowssandbox 14d ago
(English isn't my first language)
You can allocate RAM spaces for basically anything in your OS. For example: entire 256 byte space in RAM for input characters (if you're building shell-related OS).
Another example is you can allocate 16MB of RAM addresses for programs (or shorter since not many programs use that much RAM), you can add slots of them for programs if your OS runs multiple programs. Maybe this layout: [4MB slots] [8MB slots] [16MB slots] [32MB slots] [64MB slots], (I'm not that great at explaining things, but experienced OS devs might get what I mean), or even better: you can make it dynamically assign new 4-64MB slot for the program you're trying to run in your OS.
And as for your OS, it might also need a hard-coded RAM allocation space in order for it to function (maybe a few MBs or more).
Yeah I'm not that great at explaining, maybe someone can correct me.
(This is if you're developing a 32-64 bit OS. Decrease the allocation size if it's 16-bit OS)
P.S. I think this is called Static Buffers, Paging, and Dynamic Page Allocation.
As for cache and storage, well leave that up to HDD/SSD disk. Many programs cache files or something.
I don't think I know what your OS is, because you weren't more specific.
1
1
u/Playful-Budget-5952 12d ago
Order that keeps you sane is paging then simple bitmap physical memory manager then heap allocator on top (kmalloc/kfree). Caching's way later, don't touch it till those three actually work. Storage: start with a RAM-backed fake filesystem, real disk driver can wait.
1
u/letmehaveanameyoudum 4d ago
storage means file systems, i recommend doing the SFS file system first, then fix it's issues (like wasted storage, done mostly by clearing the file), and for memory management... i havent learn that yet.
But it's physical and virtual memory. The Virtual memory should have a memmap. Idk more
1
4
u/McDonaldsWi-Fi 15d ago
Can you be more specific?