Memory Protection

Memory protection means to prevent memory from being accessed or modified by programs other than the application that allocated the memory.

For example, imagine you were working in Lotus 1-2-3 and you had your (unsaved) spreadsheet open, which you had been working on for the last four or five hours. You decide to take a short break, and play a quick game of Pacman. You run the Pacman program, and you play for a while, but the Pacman program has a bug: a piece of maze wall is missing that allows Pacman to go off the screen! The game doesn't check for this, and continues to draw the "Pacman" sprite in memory - but no longer in screen memory! If just so happens that the memory next to your Pacman game was occupied by your spreadsheet data. Guess what? Now all that data has been replaced with meaningless numbers (the "Pacman" sprite) and your work is lost. Ever happen to you?

The answer is: it shouldn't have!! Most operating systems nowadays (Windows 95/98/2000/NT, beOS, Linux, OS/2, ClaireOS), with some notable exceptions (MacOS lets you turn it off !!!) include memory protection facilities, and in the above case the MMU would have detected that Pacman was attempting to write information to memory that it had not allocated (namely, the memory that had been allocated by Lotus 1-2-3) and would have generated an "exception". Windows (in this example) would have seen this exception and terminated the Pacman process immediately (if it was attempting to corrupt another processes memory, it may also have been about to start corrupting files, which are not automatically protected). Windows would then have informed the user that Pacman had caused a "General Protection Exception". You can then return to Lotus 1-2-3 and do what you should have done earlier, SAVE!