Reservations and Commitments

Most programs need memory to do their work.  Since programs don’t typically know where in memory they’re going to be loaded programs work with a virtual address space.

It’s virtual in the sense that it doesn’t correspond to any particular hardware implementation of memory.  Neither address lines nor flip-flops, the stuff of RAM that you buy in a store, spring into existence when your program refers to a location in memory.

Under the hood the operating system keeps track of where a virtual address is stored in physical memory.  On Windows the data structure that stores this mapping is called the page map.  Virtual and physical memory are divided up into equal sized blocks called pages (on x86 these pages are 4k long).

As programs start and stop, read and write and go about their business these pages are recycled (how conscientious of them!).

At any given moment a Virtual Address Space Page can be Free, Reserved or Committed.  The importance of distinguishing these states often appears when dealing with Big Data (e.g. high resolution imagery, video, audio, large volumes of text).

In many ways virtual pages are like tables at a restaurant.  Before a restaurant opens the tables may well be in a closet somewhere.  They’re free to be used but customers can’t use them just yet.  Trying to use these tables, folded and unprepared as they are, is likely to be an unpleasant experience liable to draw the ire of the restaurant owner.

Even before the tables are set and arranged a restaurant can take reservations for it.  Once reserved it can’t be reserved for someone else (unless the reservation is cancelled).  On the other hand, even though it’s reserved it’s not yet in use and might well still be folded away in a closet (since the restaurant hasn’t opened yet).

The committed state is analogous to a table that’s been placed and prepared.  It now takes up space in the building.  The customer can use the table for whatever purposes are allowed by the restaurant.

No comments:

Post a Comment