I'm implementing support for multiprocess in my OS and I don't have much experience with this. AFAIK I need to create a page directory for each process to isolate them and each page directory should map the kernel address space.
The point is: if the kernel change its address space (e.g. allocate new pages in a syscall) the page directory of other processes will became 'outdated'. I think this can cause a lot of troubles.
I found nothing about this problem in the 'literature'. This problem really exists?
Multiprocess and page directory
-
- Member
- Posts: 45
- Joined: Wed Dec 25, 2013 11:51 am
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Multiprocess and page directory
The reason you won't be able to find much documentation on it is because you added a "feature" nobody else did.
Mapping the kernel freshly in each address space is a waste of RAM because you seem to add new page tables and make them simple duplicates of existing kernel page tables. Therefore you normally use preallocated page tables for the kernel and use those by reference in every page directory. That also means that if you update the kernel address space once, you don't need to modify 100 copies of it, and you can create a fresh address space costing only 4K RAM for a single page directory, rather than one directory and several tables.
Mapping the kernel freshly in each address space is a waste of RAM because you seem to add new page tables and make them simple duplicates of existing kernel page tables. Therefore you normally use preallocated page tables for the kernel and use those by reference in every page directory. That also means that if you update the kernel address space once, you don't need to modify 100 copies of it, and you can create a fresh address space costing only 4K RAM for a single page directory, rather than one directory and several tables.
-
- Member
- Posts: 45
- Joined: Wed Dec 25, 2013 11:51 am
Re: Multiprocess and page directory
I was thinking to create the page directory of the new process and then 'copy' some entries from kernel page directory. Thus, the first 512 entries of the process PD still empty (before binary loading) and the other 512 entries is a copy of the last 512 entries of the kernel PD (my kernel uses the higher 2GB).Combuster wrote:The reason you won't be able to find much documentation on it is because you added a "feature" nobody else did.
Mapping the kernel freshly in each address space is a waste of RAM because you seem to add new page tables and make them simple duplicates of existing kernel page tables. Therefore you normally use preallocated page tables for the kernel and use those by reference in every page directory. That also means that if you update the kernel address space once, you don't need to modify 100 copies of it, and you can create a fresh address space costing only 4K RAM for a single page directory, rather than one directory and several tables.
I think its something like you said (except the preallocation). I understand that you suggest to create every PT (preallocate them) for the kernel before create the processes PDs, therefore my processes PD will have the references for all kernel page tables even them is not used yet.
It's right?
Machina - https://github.com/brunexgeek/machina
Re: Multiprocess and page directory
Hi,
Of course this isn't the only way to solve the problem, but it's definitely the easiest way; as long as you don't want to change page tables after they're pre-allocated, don't mind consuming RAM for page tables that might not actually get used, and don't have different "kernel page tables" for different cases (e.g. different page tables for CPUs in different NUMA domains).
Cheers,
Brendan
Yes. If all virtual address spaces use the same pre-allocated page tables for kernel-space; then any changes to the page table entries will effect all virtual address spaces.brunexgeek wrote:I think its something like you said (except the preallocation). I understand that you suggest to create every PT (preallocate them) for the kernel before create the processes PDs, therefore my processes PD will have the references for all kernel page tables even them is not used yet.
It's right?
Of course this isn't the only way to solve the problem, but it's definitely the easiest way; as long as you don't want to change page tables after they're pre-allocated, don't mind consuming RAM for page tables that might not actually get used, and don't have different "kernel page tables" for different cases (e.g. different page tables for CPUs in different NUMA domains).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 45
- Joined: Wed Dec 25, 2013 11:51 am
Re: Multiprocess and page directory
Great! Thanks for the help guys!
Machina - https://github.com/brunexgeek/machina