Page 1 of 1
Questions, questions questions...
Posted: Wed Feb 11, 2004 12:58 pm
by mr. x
OK, my first question is this:
When I try to set a byte at an address >= 4 MB, I get a General Protection Fault, shouldn't I get a Page Fault?
My second question:
How can I find an area in memory suitable for my heap? Seems that it's data everywhere...
Question no. 3:
Should a process have it's own selectors? If, why? My kernel selector has it's limit at 4 GB.
4th question:
How should a process' memory be mapped?
physic 0 -> 4 MB = Kernel
process 1 = physic 4 -> 8 MB
process 2 = physic 8 -> 12 MB
But what if process 1 wants to extend it's memory?
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 1:59 pm
by Adek336
OK, my first question is this:
When I try to set a byte at an address >= 4 MB, I get a General Protection Fault, shouldn't I get a Page Fault?
not sure about this one.. but I think it will fail as long as you don't set up paging (and an appropriate entry)
My second question:
How can I find an area in memory suitable for my heap? Seems that it's data everywhere...
Simple: if you've got paging, set up a constant range, for example from 0xE000_0000 to 0xF000_0000 (which is a range of 256Mb), and assign physical memory to it on demand. If you don't have paging enabled, get it just after your kernel: get your linker script to put a symbol on your kernel's end and assign the space for the heap on runtime. Be cautious not to overwrite static memory if you've got any after the kernel.
Question no. 3:
Should a process have it's own selectors? If, why? My kernel selector has it's limit at 4 GB.
I set up a dummy selector, code&data selectors for kernel (base 0 size 4Gb), code&data selectors for user(base 0 size 4Gb) and a TSS.
4th question:
How should a process' memory be mapped?
physic 0 -> 4 MB = Kernel
process 1 = physic 4 -> 8 MB
process 2 = physic 8 -> 12 MB
But what if process 1 wants to extend it's memory?
Nah, I don't recommend such a scheme. Under paging you could have one memory space for one app. The range 0xc000_0000 - 0xFFFF_FFFF would be the kernel's range, indifferent for all spaces, and 0x8000_0000 to 0xBFFF_FFFF would be the processes. So each process would be situated at virtual 0x8000_0000, and to change tasks you would have to change the address space.
[glow=red,2,300]Cheers[/glow]
edit: Why do you call yourself "Mr. X" ?
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 3:15 pm
by mr. X
OK, some things got clearer.
One thing:
I don't know LD script too well, so I couldn't manage to setup a symbol and read it in C. (I've searched the web).
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 4:01 pm
by mr. x
mr. X wrote:
OK, some things got clearer.
One thing:
I don't know LD script too well, so I couldn't manage to setup a symbol and read it in C. (I've searched the web).
I've managed to get the end of the kernel now.
One thing, is this how the kernel's memory should be split up?
Kernal | Stack | Heap ->
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 4:04 pm
by mr. x
Heh, much replying by me, but I've registered now.
The memory could maybe be split up like this?
Kernel | Heap -> <- Stack| 4 MB
btw, I don't really know why I call myself "mr. x" :/
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 4:07 pm
by nullify
Adek336 wrote:The range 0xc000_0000 - 0xFFFF_FFFF would be the kernel's range, indifferent for all spaces, and 0x8000_0000 to 0xBFFF_FFFF would be the processes. So each process would be situated at virtual 0x8000_0000, and to change tasks you would have to change the address space.
Why not use the entire address space? User space could reside from 0 to 3GB, while the kernel sits in the top gigabyte of virtual memory for each process address space.
mr. x wrote:The memory could maybe be split up like this?
Kernel | Heap -> <- Stack| 4 MB
Yes, that's the typical layout.
Re:Questions, questions questions...
Posted: Wed Feb 11, 2004 4:45 pm
by Adek336
Why not use the entire address space? User space could reside from 0 to 3GB, while the kernel sits in the top gigabyte of virtual memory for each process address space.
I wanted to leave it because I heard some blah blah that a process in virtual mode will be able to access the first 2Gb.. as I wasn't sure I wanted to leave it this way, so when I got to v86 mode and it
dir matter, I would have the framework already there and if it didn't, I would just change some bits.
Hm, it seems that I was wrong about that virtual-thing? How does it work then?
Cheers,
Adrian.
[glow=red,2,300](does this glow??)[/glow]
Re:Questions, questions questions...
Posted: Thu Feb 12, 2004 12:41 am
by BI lazy
[glow=green,2,300]with microsoft ie6 at least, it does[/glow]
In Linux-environment (which I f. ex. use at home mostly these days not only because of mydoom and consorts but because of the nifty command line tools - and the kernel development) I didn't manage to get even a fart of a glow - just red or green or whatsoever font.
Re:Questions, questions questions...
Posted: Thu Feb 12, 2004 1:28 am
by mr. x
I'm using Mozilla Firefox and all I saw was the tag :p