Paging with applications.

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
stonedzealot

Paging with applications.

Post by stonedzealot »

Okay, so I've read and read and I think I finally grasp this paging system with some level of proficiency. The one question I have is that when you have two programs that have to run in the same place in memory what do you do?

On instinct I say that you'd just rebind the virtual addresses to new physical addresses but then how do you remember what the old process' bindings were? Do you just keep that with whatever process information you have?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Paging with applications.

Post by Pype.Clicker »

stop thinking of programs: think of processes. You can have to processes mapping different programs at the same virtual address, as there will be in separate address spaces ... they will not interfere with each other ...

let's say you have process A = { 1, 4, 5, 6} and process B = {1, 2, 3, 6}. The pages 4 and 5 hold the program A and the pages 2 and 3 map the program B. page "1" is the system and page 6 contains a shared library

for both programs, the memory layout looks like
0x0000 .. 0x3FFF : kernel (system)
0x4000 .. 0x7FFF : program code (user, read-only, execute)
0x8000 .. 0xBFFF : program stack (user, read/write)
0xC000 .. 0xFFFF : gfx.shlib (user, copy-on-write)

but there are actually two set of 0x0000 .. 0xFFFF virtual addresses, depending on how you load the page directory register.
stonedzealot

Re:Paging with applications.

Post by stonedzealot »

Okay, so there are multiple page directories, one for each process?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Paging with applications.

Post by Pype.Clicker »

right. That's the multiple-address space model used in Unix, Windows and most modern OSes ... only very specific hardware devices (like routers) keep on the Single Address Space model.

Another option is to give each process a group of segments which will have different base and will not overlap, so that you can actually put them at different linear addresses within the same address space, but keep them seeing their own logical addresses.
This has less the developer's preferences, though, as IA-32 is one of the rare segmented architecture ...
stonedzealot

Re:Paging with applications.

Post by stonedzealot »

Thanks alot, Pype!
Post Reply