Magic problems in the memory manager.

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
User avatar
mrjbom
Member
Member
Posts: 317
Joined: Sun Jul 21, 2019 7:34 am

Magic problems in the memory manager.

Post by mrjbom »

Hi.
To display text on the screen, I use Scalable Screen Font, it needs a memory manager.
I wrote code that outputs text, in qemu it works as it should and outputs everything. But when trying to run the kernel in Virtual Box, the library reported errors in my memory Manager. Later, I noticed that in virtual box the test machine has 5120 MB of RAM, so I lowered this number to 1024 and everything worked fine.
I thought I found an error, I thought that when working with more than 4 GB of RAM in the memory Manager there is a problem.
Then I put 4100 MB to test my guess, but everything worked.
Experimentally, I found out that if I put 4132 MB or higher I get a problem. At 4131 MB, everything works well.

I did not apply the source code of the memory Manager because the comments are not written in English(I will translate them later). But if someone wants to look at them, you can find them all here.

What could be the reason for this problem?
Thanks.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Magic problems in the memory manager.

Post by iansjack »

Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Magic problems in the memory manager.

Post by Octocontrabass »

Your problem is here. You are casting memory_map->addr and memory_map->len to uint32_t, but they do not fit in 32 bits.
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Magic problems in the memory manager.

Post by Octocontrabass »

iansjack wrote:Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?
With PAE, a 32-bit OS may access the entire physical address space (up to 52 bits on current processors).

Of course, if you're using anywhere near that many physical address bits, you'd probably be better off in long mode.
User avatar
mrjbom
Member
Member
Posts: 317
Joined: Sun Jul 21, 2019 7:34 am

Re: Magic problems in the memory manager.

Post by mrjbom »

Octocontrabass wrote:Your problem is here. You are casting memory_map->addr and memory_map->len to uint32_t, but they do not fit in 32 bits.
Thanks for the help. I was surprised why when installing for example 4131 MB everything works, and if a little more, everything breaks. Now I understand.

Love you.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Magic problems in the memory manager.

Post by iansjack »

Octocontrabass wrote:
iansjack wrote:Are you asking why your 32-bit os doesn't work with more than 4GB of RAM?
With PAE, a 32-bit OS may access the entire physical address space (up to 52 bits on current processors).
Well, yes. But that rather supposes that you are using PAE.
iProgramInCpp
Member
Member
Posts: 81
Joined: Sun Apr 21, 2019 7:39 am

Re: Magic problems in the memory manager.

Post by iProgramInCpp »

Isn't that supposed to be 4096? I mean 4096 MiBytes (p.c.) = 4194304 KiBytes = 4294967296 (1 over the max value for a uint32_t)
Hey! I'm developing two operating systems:

NanoShell --- A 32-bit operating system whose GUI takes inspiration from Windows 9x and early UNIX desktop managers.
Boron --- A portable SMP operating system taking inspiration from the design of the Windows NT kernel.
Post Reply