Virtual paging?

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.
Kemp

Virtual paging?

Post by Kemp »

Something occured to me. On current "64-bit" systems the available memory space is a lot bigger than the 4Gb a program is allowed to use. Does this open the way for paging memory out to other memory areas? Essentially the same operation as paging to a hard drive but much much faster going in and out. Would be relatively simply to remap memory to just include the source and destination, copy, and then switch back to the application's memory space. Of course, I'm assuming this is a case where an app needs more than the (4Gb - OSSpace) that is available, if you manage to go over physical memory it'd obviously still be back to disk paging.
User avatar
Colonel Kernel
Member
Member
Posts: 1437
Joined: Tue Oct 17, 2006 6:06 pm
Location: Vancouver, BC, Canada
Contact:

Re:Virtual paging?

Post by Colonel Kernel »

Wouldn't it be easier to just port apps to use 64-bit pointers and thereby use more of the address space...?
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!
JoeKayzA

Re:Virtual paging?

Post by JoeKayzA »

Kemp wrote: Essentially the same operation as paging to a hard drive but much much faster going in and out.
I can't see how this is similar to paging memory out to disk, I mean, when you do swapping, the app itself won't notice that a page has been swapped out - the virtual page is still there. When it is accessed then, the OS has to fetch it back from disk and make it accessible - again the app won't notice.

When you want to reuse virtual pages (when the app needs more than 4Gb of address space), the app itself will have to notify the OS when it wants to swap a page, so that's an entirely different thing to me.

And, btw, I would also say that an app which needs more virtual memory than the OS can provide in 32bit mode should be ported to run in 64bit mode. Especially when it relies on a 64bit OS to run underneath.

cheers Joe
JAAman

Re:Virtual paging?

Post by JAAman »

it wouldn't be paged: the pages (while in physical memory) can be located anywhere in physical memory -- you can't 'page' out to ram because if its in ram its accessable (and therefore unswapped)

you can have several apps entirely within physical memory (in 32bit mode under a 32bit OS) if you have enough physical memory: pages can be mapped anywhere -- not just to a 4GB block at bottom_of_mem

if an app needs more than the availible virtual address space, most OSs (incl. windows, and, eventually, JaaOS), allow it to swap out portions of its address space this normally is swapped to disk but i would imagine that it could be done within physical memory -- but you would need to set up a method of tracking it since it would not exist within any address space (however i will be creating a special class of address spaces that contain 'overflow' from another address space)

-- note this technique of swapping virtual memory (to enlarge an address space) is normally called 'banking' not 'paging' (which normally refers to swapping physical memory -- to increase physical memory)
Kemp

Re:Virtual paging?

Post by Kemp »

Yeah, the intention wasn't that you should fixate on the term 'paging', I just used that as it was the closest analogy I come think of off the top of my head.

The last I heard was that even under 64-bit mode a single virtual address space could only be 4Gb maximum still. Obviously if I heard wrong then this discussion is kinda moot.
JAAman

Re:Virtual paging?

Post by JAAman »

no, under LMode, your address space is much larger
however this is still valid question under PMode, as any CPU in the last 10 years can support up to 64GB ram (and the newer ones allow 1TB -- even in PMode)

this has been a common technique as far back as RMode programs running under DOS can use more than the RMode limit, using banking (where a 64KB (or smaller) block of data/code is 'swapped' to extended memory (through an extended memory manager) and then can be restored later, to increase the total memory availible within a true RMode environment

there was even a standardized driver for this (which worked with both extended and expanded memory depending on which was installed and the application didn't even need to know which was being used) the most popular of which is emm386 (because it came bundled with most computers -- bundled with both DOS and win3)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Virtual paging?

Post by Candy »

Kemp wrote: Yeah, the intention wasn't that you should fixate on the term 'paging', I just used that as it was the closest analogy I come think of off the top of my head.

The last I heard was that even under 64-bit mode a single virtual address space could only be 4Gb maximum still. Obviously if I heard wrong then this discussion is kinda moot.
You heard that wrong. An address space is at least 40 bits (1024 GB), and iirc it was 48 bits (262144GB) in all AMD implementations of AMD64.
Kemp

Re:Virtual paging?

Post by Kemp »

Hmmm.... must have been a communication issue somewhere along the line then. I'll see if I can find the threads where I remember reading it, see if I accidently took something out of context.
JAAman

Re:Virtual paging?

Post by JAAman »

or get an updated copy of the holy bible intel manuals
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Virtual paging?

Post by Candy »

JAAman wrote: or get an updated copy of the holy bible intel manuals
*cough* for AMD64, you might just want the AMD manuals.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Virtual paging?

Post by Brendan »

Hi,
Candy wrote:*cough* for AMD64, you might just want the AMD manuals.
Does AMD actually have proper programmer's manuals? All I've seen are documents that describe differences between AMD CPUs and the Intel manuals (e.g. 3DNOW extensions, AMD64 extensions, CPU datasheets, BIOS developers manuals, optimization, etc)...


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Virtual paging?

Post by Candy »

Brendan wrote: Hi,
Candy wrote:*cough* for AMD64, you might just want the AMD manuals.
Does AMD actually have proper programmer's manuals? All I've seen are documents that describe differences between AMD CPUs and the Intel manuals (e.g. 3DNOW extensions, AMD64 extensions, CPU datasheets, BIOS developers manuals, optimization, etc)...
Yes. See image for proof (picture of my own hardcopy).
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Virtual paging?

Post by Candy »

For links: Volume 1, Volume 2, Volume 3, Volume 4, Volume 5.

The photo is of volume two, which is of course the System Programming manual. The picture was taken with my telephone on night mode, which of course doesn't give a very good image. You should still be able to recognise it.

Let's add the pacifica virtualization manual to the list.

[edit] you can't add an image in modify? that's wrong. [/edit]
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:Virtual paging?

Post by bubach »

Where did you get a hardcopy? You didn't go to USA or Canada just to order one, did you? ;D
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Virtual paging?

Post by Candy »

bubach wrote: Where did you get a hardcopy? You didn't go to USA or Canada just to order one, did you? ;D
* Available only in the US and Canada.
International users, please download the documents
Just be an arse and fill in Saskatchewan, Canada and put in the comment field "NOT SASKATCHEWAN BUT HOLLAND, EUROPE" with full address. Does increase the delivery time though... mine took 3 months...
Post Reply