How to allocate multiple pages without multiple page tables
-
- Member
- Posts: 70
- Joined: Tue Jul 14, 2020 4:01 am
- Libera.chat IRC: clementttttttttt
How to allocate multiple pages without multiple page tables
Is there any way to allocate multiple pages without a large amount of page tables? I can't think of anyway of doing this,
-
- Member
- Posts: 5572
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to allocate multiple pages without multiple page tab
That's a strange question. Why do you want to do that?
Each page table has 1024 (without PAE) or 512 (with PAE) entries, which covers 4MiB / 2MiB of address space.
Each page table has 1024 (without PAE) or 512 (with PAE) entries, which covers 4MiB / 2MiB of address space.
-
- Member
- Posts: 70
- Joined: Tue Jul 14, 2020 4:01 am
- Libera.chat IRC: clementttttttttt
Re: How to allocate multiple pages without multiple page tab
I'm currently porting liballoc, and it need a page map/unmap function. I will also implement multitasking in my os, and multiple programs might run malloc, which will call the page map functions multiple times.Octocontrabass wrote:That's a strange question. Why do you want to do that?
Each page table has 1024 (without PAE) or 512 (with PAE) entries, which covers 4MiB / 2MiB of address space.
-
- Member
- Posts: 5572
- Joined: Mon Mar 25, 2013 7:01 pm
Re: How to allocate multiple pages without multiple page tab
Does each program get its own address space, like a typical OS? If so, memory allocations in one program will not affect the others (as long as you have enough available memory).
Do all programs share a single address space, like some embedded OSes? If so, you'll probably need to determine which program is calling the page map functions in order to allocate memory within that program's portion of the address space.
Do all programs share a single address space, like some embedded OSes? If so, you'll probably need to determine which program is calling the page map functions in order to allocate memory within that program's portion of the address space.
-
- Member
- Posts: 70
- Joined: Tue Jul 14, 2020 4:01 am
- Libera.chat IRC: clementttttttttt
Re: How to allocate multiple pages without multiple page tab
Actually I haven't implemented multitasking yet, but I'm definitely going to let programs have its own address space.Octocontrabass wrote:Does each program get its own address space, like a typical OS? If so, memory allocations in one program will not affect the others (as long as you have enough available memory).
Do all programs share a single address space, like some embedded OSes? If so, you'll probably need to determine which program is calling the page map functions in order to allocate memory within that program's portion of the address space.
-
- Member
- Posts: 426
- Joined: Tue Apr 03, 2018 2:44 am
Re: How to allocate multiple pages without multiple page tab
So long as your mappings are clustered together, the amount of page table memory you'll use per process should be small. A 4K page table will map 4MB of virtual memory, fully utilised. So, if your process is less than 4MB in size, it could occupy only one page table (plus your page directory + kernel mappings,) which isn't very much memory.clementttttttttt wrote:Is there any way to allocate multiple pages without a large amount of page tables? I can't think of anyway of doing this,
If you treat your page tables as disposable, then you can just have a pool of page table pages set aside, and reuse page tables that haven't been referenced in a while. Using demand paging, the contents of the page tables can be transient, and will be built back up as they're referenced.