************* TITLE: protected mode memory ************************************* Title: Protection Memory in mode ****************** ================= translated from tutor by hutch ====== ============ ** ==== Original: collect and packed by Dreamtheater ==== ** ====== Translate: Small bridge from qdu huasoft@163.com== ========== ** ========================================== == ********************************************************** *********
Protected mode memory
In a real mode operating system like DOS, you can overwrite the code segment of the operating system. If the program does not write correctly, this is likely to cross the entire operating system, and the computer can only run.
If you are writing such a program: write directly to the CGA graphics memory area, the program starts at B800H, and a loop error is displayed in the code, which will overwrite the entire area until the maximum address range of DOS. This will overwrite everything and include BIOS settings in memory.
The memory in protective mode is designed to prevent this similar thing. A memory manager in a protective mode controls the address range written by the application. If this application continues to write those non-written addresses, the manager will terminate this application.
This memory management is available in 16-bit Windows, but because 16-bit Windows simulation multitasks, it can override other applications memory areas, or operating systems.
Depending on the contents of overwritten in the operating system, some other programs that do not have erroneous programs can call the operating system function, whether it is a program or an operating system. More common is that you have received "Blue Screen", which tells you a little information; but if you have written a lot of code, it has produced too big chaos, you receive "black screen death", a direct black screen locks the machine Nothing to tell you anything.
Hardware improvements and hardware-based 32-bit multitasking make memory management in protection more credible. The basis of writing code in the operating system of the protection mode is: just read and write the memory you are permitted by your application.
Because the compiler allows you to read and write almost any address range, you need to pay attention to the memory range you can read and write. If you assign 10K buffering but when you try to read 20K, the address has received a memory page read error after the address is over 10K buffer. If you abandon a variable in the register and try to read the address, you will also encounter trouble because you exceed the range of addresses.
Page read-write errors are "Exceptions", which is an error caused from operating systems to the application. If the exception is not graspful by the application, the operating system will turn off the program. This provides some ways to protect applications away from address range errors. In multi-task operating systems, when the multi-channel program is running, if this protection is not available, then a program may overwrite the memory of another running program, which makes the program in another run collapsed. The same problem also occurs in the code of the operating system: a program overwriting the code of the operating system will collapse the operating system. ==============================================