paging (split from Screen Shots)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
trolly
Member
Member
Posts: 52
Joined: Tue Mar 25, 2008 12:26 pm

paging (split from Screen Shots)

Post by trolly »

I finaly managed to enable paging, i have imported the VMM code of frost OS and adapted to my kernel. i understand well how it works now

like frost, it doe not use High Half kernel model:
* the kernel is identity maped to itself , also the console buffer, the vesa lfb are identity mapped
* the gui thread and the idle thread use the kernel's page directory
* each processes have they page directory
* the thread uses the page directory of the owner process
* when the scheduler switch to the thread, it activate the thread's page directory
* when i load a process from an executable (a flat binary): it create a new page directory for it, and activate it; so it can copy the binay data to the app address's space (0x40000000 or 1GiB)
* when a page directory is activated, it is automaticaly synced with the previous page directory (the bottom 255 entries corresponding to the first Gib is copied, so the kernel space is always sync accross all pages directories)

it work well when i load multiples processes before the timer is enabled:
* each process runs, and can receive events from the kernel

i have only a problem when the process ask the kernel to load an executable trought a syscall; the process is well created, and the task also. but when the scheduler switch to that newly created task, it returns a page fault, saying that a page is not present. (this bug does'nt occurs when the process is asking to create a thread in it's address space)

Note: when i alocate a physical page (in KMM.bas, method 'PageAlloc') , i map it to a free hole (bellow the 1 gig limit) int the current's context page directory and return the virtual address => normaly when i switch to another task this new mapping should be also synced

for now, the only workaround i have found, is to identity map the physical memory to itself (512 MB with qemu) , when i do that, all work well, there is no more pagefault. but this situation is not ideal (it will not work if there is more than 1gib in the machine)

the code is shared in my github at https://github.com/stephaneweg/little-os
maybe someone can look at it and see if he could find a problem with my logic (somewhere in Kernel/Src/Process.bas, kernel/Src/Thread.Bas, kernel/Src/KMM.bas , kernel/SRC/VMM.Bas , kernel/SRC/Scheduler.bas)
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: paging (split from Screen Shots)

Post by klange »

The thread you originally posted this in is for screenshots, I have split your post to its own thread.
Post Reply