PDA

View Full Version : Virtual Memory and The way it works????


Beno
05-01-2001, 11:50 PM
Hi there Every1,

Want to know some more detail on Virtual Memory and the way it works.
My textbook explains it in a very difficult manner indeed.

So as I understand it, the CPU generates a memory address (or is it the Op.Sys????), this memory address is a virtual address that can be translated into a logical address or a physical address.

What happens is that the virtual address goes to a Page lookup table and checks if the page is in Physical Memory and then......................
(you fill in the rest if you can.......).

This is where I get stuck!!

Please help if you can.

Cheers

------------------
Have a nice day

mjc
05-02-2001, 12:26 AM
Try here for some more easily undertandable explinations http://www.pcguide.com/ref/ram/sizeVirtual-c.html

------------------
mjc
Links list:Computer Links (http://www.fortunecity.com/skyscraper/highrise/11/index.htm)

Beno
05-02-2001, 01:05 AM
Thanks mjc,

but I have read that page already, and is not very detailed for my liking.
I want something that will explain to me the VM System in step by step detail and how it interacts with the CPU, RAM and Secondary Storage.

So if you have any info like that, then I would heaps appreciate it.

Cheers

Ben

------------------
Have a nice day

mjc
05-02-2001, 01:26 AM
So you want something between that and a textbook? You follow the links through? Only other I've got is a textbook. You try Google (http://www/google.com) with Virtual Memory as a keyword? Only 874,000 hits.....

------------------
mjc
Links list:Computer Links (http://www.fortunecity.com/skyscraper/highrise/11/index.htm)

Beno
05-02-2001, 02:29 AM
Just because there are a ****load of links doesn't mean there going to answer my question or be any good now are they!!

------------------
Have a nice day

[This message has been edited by Paleo Pete (edited 05-03-2001).]

mjc
05-02-2001, 09:51 AM
Sorry Ben if I made you mad but I was trying to get you to a little more of the lookling yourself, I gave my answer: I've got a text that explains it about the same as yours does and then Ixl's description in the Guide pages. I have had good results in the past by the "search within results" function and adding more keywords to narrow it down a little. Anyway, a number of the hits on the first few pages that Google returned came to the Guide......

------------------
mjc
Links list:Computer Links (http://www.fortunecity.com/skyscraper/highrise/11/index.htm)

Ghost_Hacker
05-02-2001, 10:55 AM
Here's some information on NT's virtual memory manager you may find interesting. There are other threads in this forum that explain Pages and memory addressing. A poster by the name of "bunk" has a excellent one on memory addressing.

Hope this helps http://www.PCGuide.com/ubb/smile.gif


The Virtual-Memory Manager (VMM)

The virtual-memory manager in Windows NT is a separate process that is primarily responsible for managing the use of physical memory and pagefiles. To do this, it must track each page of physical memory, tune the working set of all active processes, and swap pages to and from disk both on demand and routinely. The VM manager is an executive component of Windows NT that runs exclusively in kernel mode. Because of the time-critical nature of the code that is executed by the virtual-memory manager, the VMM code resides in the small section of memory called nonpaged pool. This memory is never paged to disk.

The Page-Frame Database
The virtual-memory manager uses a private data structure for maintaining the status of every physical page of memory in the system. The structure is called the page-frame database. The database contains an entry for every page in the system, as well as a status for each page. The status of each page falls into one of the following categories:

Valid--- A page in use by an active process in the system. Its PTE is marked as valid.

Modified--- A page that has been written to, but not written to disk. Its PTE is marked as invalid and in transition.

Standby-- A page that has been removed from a process's working set. Its PTE is marked as invalid and in transition.

Free --A page with no corresponding PTE and available for use. It must first be zeroed before being used unless it is used as a read-only page.

Zeroed-- A free page that has already been zeroed and is immediately available for use by any process.

Bad-- A page that has generated a hardware error and cannot be used by any process in the system.


Most of the status types are common to most paged operating systems, but the two transitional page status types are unique to Windows NT. If a process addresses a location in one of these pages, a page fault is still generated, but very little work is required of the VMM. Transitional pages are marked as invalid, but they are still resident in memory, and their location is still valid in the PTE. The VMM merely has to change the status on this page to reflect that it is valid in both the PTE and the page-frame database, and let the process continue.

The page-frame database associates similar pages based on each page's status. All the pages of a given type are linked together via a linked list within the database; see Figure 7. These lists are then traversed directly according to status. This enables the VM manager to locate three pages marked Free, for example, without having to search the entire database independently for each Free page. Another way of thinking of the database entries is to consider them as existing in six independent lists, one for each type of page status.

Each page-frame entry in the database also reverse-references its corresponding PTE. This is necessary so that the VM manager can quickly return to the PTE to update its status bits when the status of a page changes. The VM manager is also able to reverse-reference prototype PTEs to update their status changes, but note that the prototype PTE does not reverse-reference any of its corresponding PTEs.

The VMM uses the page-frame database any time a page of memory is moved in or out of memory or its state changes. Take, for example, a process that attempts to address a specific memory location in a page that had been paged to disk. The translation for this virtual address would generate a page fault as soon as an attempt to access the page referenced by the PTE occurred. The VMM would then allocate a physical page of memory to satisfy the request. Depending on the current state of the system, allocating a page may be as easy as changing the PTE for the page to Valid and updating the page-frame database for that page; such is the case for transitional pages as described above. On the other hand, the VMM may be required to steal a Modified page from another process; write the page to disk; update the PTE in the page table of the other process as not in transition; zero the page; read in the new page from a pagefile; update its PTE to indicate a valid page; and update the page-frame database to represent the physical page as Valid.

Periodically, the VMM updates the page-frame database and the state of transitional pages in memory. In an effort to keep a minimum number of pages available to the system at all times, the VMM moves pages (figuratively speaking) from either the Modified or Standby list to the Free list. Modified pages must be written to disk first and then marked as Free. Standby pages do not need to be written because they are not dirty. Free pages are eventually zeroed and moved to the Zeroed list. Pages in the Free and Zeroed lists are immediately available to processes that request pages of memory. Each time a page is moved from one list to the next, the VMM updates the page-frame database and the PTE for the page. It is important to note that pages in either of the transition states are literally in transition from Valid pages to Free pages.

Managing a Working Set of Pages for Each Process
Another part of the VMM gets pages into the transitional state. The thread that gets transitional pages must continually decide what data is most deserving of replacement on a process-by-process basis. The algorithm for deciding which page to replace is typically based on predicting the page that is least likely to be needed next. This prediction is influenced by factors such as what page was accessed least often and what page was accessed the longest time ago. In Windows NT, the component responsible for making these predictions is called the working-set manager.

When a process starts, the VMM assigns it a default working set that indicates the minimum number of pages necessary for the process to operate efficiently (that is, the least amount of paging possible to fulfill the needs of the process without starving the needs of other processes). The working-set manager periodically tests this quota by stealing Valid pages of memory from a process. If the process continues to execute without generating a page fault for this page, the working set is reduced by one, and the page is made available to the system. This test is performed indiscriminately to all processes in the system, providing the basis for the free pool of pages described above. All processes benefit from this pool by being able to allocate from it on demand.

The act of stealing a page from a process actually occurs in two stages. First, the working-set manager changes the PTE for the page to indicate an invalid page in transition. Second, the working-set manager also updates the page-frame database entry for the physical page, marking it as either Modified or Standby, depending on whether the page is dirty or not.



------------------
Comment heard from a Klingon programmer.

"Klingon function calls do not have 'parameters'. They have 'arguments'....and they ALWAYS WIN THEM!"

helldiverCDN
05-02-2001, 10:57 AM
Try the following link, and see sections on Virtual Memory, and multitasking.
http://cwdixon.home.texas.net/support/win98_support/index.htm


Cheers,

hell out


[This message has been edited by helldiverCDN (edited 05-02-2001).]

bunk
05-02-2001, 03:55 PM
What happens is that the virtual address goes to a Page lookup table and checks if the page is in Physical Memory and then......................
(you fill in the rest if you can.......).

If the page is in the the physical memory it will then use the address to locate it on the RAM and pull it to the cpu. If it is not in the physical memory it will go to the virtual memory on the harddisk and locate it there. If it is located in the virtual memory it will make room in the physical memory for the page(s) then copy the page(s) from the harddisk to the physical memory. Once the page(s) is in the physical memory the cpu can access it.

Paleo Pete
05-03-2001, 09:27 AM
Beno:

1. Please watch the language.

2. Try your local library or school library.

3. These people don't normally answer homework type questions at all, so consider yourself lucky, they seem to be trying to help you, apparently since you stated that your books do not go into sufficient detail. Spitting back indignant replies probably will not encourage most of them to try much harder.

------------------
So many idiots, and only six bullets...
Note: Please post your questions on the forums, not in my email.

Computer Information Links (http://www.geocities.com/paleopete/)

sea69
05-03-2001, 09:44 AM
BENO????

I'm surprised m8 http://www.PCGuide.com/ubb/frown.gif

#1) RULE here, (unwritten).. DO NOT insult the people you are asking for help.

#2) If you got Pete to EDIT your post, it MUST have been REALLY rude.. cause he doesn't like to do this.

and #3) If you insult one of us here.. you insult ALL OF US.. and trust me, that will NOT be advantageous to you, (if you want help in the future)

I have seen you post before, and you acted like you had some common sense.. what happened?? we all have BAD days.. trust me...look at some of my posts...........

better chill it.. or who knows....... you may find that NOBODY will answer your questions...

I speak only for myself on this.


------------------
sea1_69@hotmail.com

homepage (http://www.seanweb1.homestead.com/3.html)

[This message has been edited by sea69 (edited 05-03-2001).]

Beno
05-03-2001, 10:09 AM
Ok Guys,

I apologise to you all especially mjc and Paleo Pete and Sea69, yes I was having a bad day!!

Paleo Pete, its not school mate but university........and its not a current subject of mine.......but just something for which I have interest in and could not be bothered to go to the library. Why bother when you have websites like this and search engines like Google!!

Anyway......I love this website so I apologise to anyone that got offended.

Cheers

Beno

------------------
Have a nice day

Paleo Pete
05-04-2001, 04:40 PM
No problem Beno...

The point, I suppose, is that we rarely hand it to you on a silver platter. If we post our suggestions, links and advise in a manner that makes you work for it, but at least helps you find it, you'll learn from it and therefore help yourself. If we do the searching and spend an hour trying to find exactly what you're after, chances are you'll forget it. I know someone who still can't remember how to run scanreg and restore the Win98 registry after I've walked them through it 3 or 4 times. Why bother to commit it to memory when you can pick up the phone?

That's why your original post got links and search engines, instead of detailed info. If you don't work/pay for it chances are you won't remember it. Usually we don't answer homework type questions at all, but since you explained that you didn't get satisfactory results from the textbooks, the folks here thought it would be acceptible to help out. That's fine with me, but I would have done the same as they did, point you to places to search for it yourself. Then after you spend hours searching like I do, you'll definitely remember what you learned, and I find that I often pick up lots of extras along the way that may have nothing to do with my original search.

So go looking. http://www.PCGuide.com/ubb/smile.gif

------------------
So many idiots, and only six bullets...
Note: Please post your questions on the forums, not in my email.

Computer Information Links (http://www.geocities.com/paleopete/)

sea69
05-04-2001, 05:10 PM
"Then after you spend hours searching like I do, you'll definitely remember what you learned, and I find that I often pick up lots of extras along the way that may have nothing to do with my original search."


100%

http://www.PCGuide.com/ubb/wink.gif

------------------
sea1_69@hotmail.com

homepage (http://www.seanweb1.homestead.com/3.html)

[This message has been edited by sea69 (edited 05-04-2001).]

Paleo Pete
05-05-2001, 09:08 AM
Sea...how do you think I found the PC Guide in the first place? http://www.PCGuide.com/ubb/biggrin.gif

Come to think of it, about half the links on my page are there as a result of incidental finds while searching for specific information.

------------------
So many idiots, and only six bullets...
Note: Please post your questions on the forums, not in my email.

Computer Information Links (http://www.geocities.com/paleopete/)

sea69
05-05-2001, 09:13 AM
hehe .. yep me tooooooooooooo !!

http://www.PCGuide.com/ubb/wink.gif

------------------
sea1_69@hotmail.com

homepage (http://www.seanweb1.homestead.com/3.html)