12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

356 chapter 14ADBCFigure 14.4 Multitasking of four programs in memory at one time in which the programs areexecuted in round-robin order.As shown in Figure 14.2 for our example, virtual memory permits your programto use more pages of memory than can physically fit into RAM at one time. Acombination of operating system and hardware maps this virtual memory intopages with typical lengths of 4–16 KB. Pages not currently in use are stored inthe slower memory on the hard disk and brought into fast memory only whenneeded. The separate memory location for this switching is known as swap space(Figure 14.2). Observe that when the application accesses the memory location forM[i][j], the number of the page of memory holding this address is determined bythe computer, and the location of M[i][j] within this page is also determined. A pagefault occurs if the needed page resides on disk rather than in RAM. In this casethe entire page must be read into memory while the least recently used page inRAM is swapped onto the disk. Thanks to virtual memory, it is possible to runprograms on small computers that otherwise would require larger machines (orextensive reprogramming). The price you pay for virtual memory is an order-ofmagnitudeslowdown of your program’s speed when virtual memory is actuallyinvoked. But this may be cheap compared to the time you would have to spend torewrite your program so it fits into RAM or the money you would have to spendto buy a computer with enough RAM for your problem.Virtual memory also allows multitasking, the simultaneous loading into memoryof more programs than can physically fit into RAM (Figure 14.4). Although theensuing switching among applications uses computing cycles, by avoiding longwaits while an application is loaded into memory, multitasking increases the totalthroughout and permits an improved computing environment for users. For example,it is multitasking that permits a windows system to provide us with multiplewindows. Even though each window application uses a fair amount of memory,only the single application currently receiving input must actually reside in memory;the rest are paged out to disk. This explains why you may notice a slight delaywhen switching to an idle window; the pages for the now active program are beingplaced into RAM and the least used application still in memory is simultaneouslybeing paged out.−101<strong>COPYRIGHT</strong> <strong>2008</strong>, PRINCET O N UNIVE R S I T Y P R E S SEVALUATION COPY ONLY. NOT FOR USE IN COURSES.ALLpup_06.04 — <strong>2008</strong>/2/15 — Page 356

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!