Patrick Sanford
Patrick Sanford

Reputation: 135

Are my thoughts about memory management and paging correct?

I'm attempting to write my own operating system, and have gotten to the point where I have to consider memory management and paging. This has shown itself to be a bit more challenging than I anticipated. :-D Before I attempt another failed implementation I'd like to have my thoughts about the subject in order.

To my understanding, in order to properly implement paging in C on a 32-bit x86 system I should:

Create a memory manager I...

To set up paging, I then have to create a page directory (in the first page?), and 1024 page tables containing 1024 pages. I then put the address of the page directory in the Cr3 register, and change a bit in the Cr0 register. At this point I'll also need new functions to allocate and free pages through the page directory.

Is my thinking on all of this correct? If not, what am I failing to understand? What do I need to do to keep the system from trying to access non-existent memory?

Upvotes: 1

Views: 236

Answers (1)

roger314
roger314

Reputation: 46

You will also need to write the page fault exception handler and insert it into the table of interrupts for whatever processor you are using. This handler will perform the search through the page tables when there is a TLB miss. Each process will have its' own set of page tables mapping virtual to physical addresses.

Upvotes: 1

Related Questions