
I am currently proceeding my development on my operating system.
By now paging works as follows: The kernel has its own directory. I can create user space directories by giving a start and end address (Paging::createUserspace(0x10000000, 0x20000000) for example). To do that I copy the kernel directory to a blank directory, create new pages for user space and insert them into the new directory. Is this approach correct?
So now the time has come for me to implement multitasking, but I have a little problem understanding it right. This is how I got it:
- Paging is enabled & user directory exists
- Current directory is kernel directory
- The scheduler calls
- Store the kernel register values
- Switch to the user directory
- Restore the processes register values
- Let the process work until scheduler calls
- Store the process register values
- Switch back to kernel directory
- Restore the kernel register values
- Repeat
Is this right? The only problem I have there is, if I copy the kernel directory to the user space directory to keep executing, isnt there the danger that the user code could change the contents of my kernel memory? Do I really have to copy the kernel directory or is there another way?
Thanks in advance!
