Building your own Operating System (Week 08)

Managing Available Memory

Reading the multiboot structure provided to us by GRUB is the simplest approach to determine available memory. GRUB gathers the memory information we require, such as what is reserved, I/O mapped, read-only, and so on. We must additionally ensure that the memory utilized by the kernel is not marked as free (because GRUB does not identify this memory as reserved). Exporting labels at the beginning and end of the kernel binary from the linker script is one approach to figure out how much memory the kernel uses.

How Can We Access a Page Frame?

The page frame allocator returns the page frame’s physical start address. There is no page table that points to this page frame since it is not mapped in.

Kernel Heap

We can implement malloc and free to use in the kernel now that we have a page frame allocator. The page frames provided by the page frame allocator must also be mapped to virtual addresses. To do it first we need the “kheap.h” header file.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store