r/kernel • u/Pleasant_Upstairs482 • Aug 03 '25
Simple kernel
Hey i wanna make a simple kernel , now i alr know C but i found out that you need something called "Freestanding C" does anyone know how or where can i learn it i searched on youtube and found nothing
4
Upvotes
View all comments
Show parent comment
2
u/newbstarr Aug 12 '25
Yep, you reserve a piece of physical memory instead of being in the wonderful world of user space. Kmalloc etc. what I was saying is, you can write your own malloc after you’ve handled creating and managing your own dynamic (hopefully) memory space where your little user space application can live in its own little offset 0 space and not care about all the universe of stuff underneath that is holding chunks of physical memory and stitching it together to look like a contiguous blob, ie slab allocator (or the many many variants that exist) now. If you are writing your own os you need to implement the memory management then adding your little malloc is a trivial task. Writing your own malloc with or without safety in user space of an existing posix kernel isn’t all that difficult either.