VOGONS


First post, by Lazarus

User metadata
Rank Newbie
Rank
Newbie

Hi DOSBoxers,

I'm trying to get DOSBox to build with a smaller memory footprint. At the moment, the PagingBlock object is 16Mb in size. I have a fair understanding of x86 CPU emulation, but I'm not sure why TLB_SIZE is so big (1024*1024). As far as I can see, the TLB_SIZE does not need to be bigger than the total amount of RAM available to the emulation / 4096. If I limit MAX_MEMORY to 16Mb, then it seems that I can get away with a TLB_SIZE of 4096 (16*1024*1024/4096). Am I missing something?

Thanks,

I

Reply 1 of 2, by Srecko

User metadata
Rank Member
Rank
Member

I think you can't make it smaller:
That structure adresses all 4k pages in 32-bit adressing space (4-gig).
CPU can link any page to a 4k page in physical memory.
So if protected mode program decides to use memory space, say, at the end of linear adress space, CPU will link that part to somewhere in physical memory.
So, (If I'm correct, and I can easily be wrong:)) you can't reduce TLB_SIZE. (well, maybe you can but only real mode programs will work correctly).

Reply 2 of 2, by Lazarus

User metadata
Rank Newbie
Rank
Newbie

Hi DOSBoxers,

OK, I guess I can't just change TLB_SIZE. I don't want to change the behaviour of DOSBox in any way (certainly not in a way that reduces compatibility). However, I do need to reduce the memory footprint substantially (at least for real-mode configurations). So what I've done is implement demand-paging for the memory allocated for the PagingBlock. This seems to work well, typically reducing the amount of RAM needed initially (and in real-mode) by 12Mb. I did notice that there seems to be 4Mb of wasted space in PagingBlock though: The PagingBlock object contains a member called "tlb.phys_page[TLB_SIZE]". This member is assigned in PAGING_LinkPage(), but is never used anywhere, so I've #ifdef'd it out. Everything still seems to work, but I guess it is (was?) there for a reason. Anybody know anything about "tlb.phys_page[TLB_SIZE]"?

TIA,

I