Protected Mode - Overview

foreword

Protected mode is a working mode of the CPU, which is closely related to the operating system. In fact, no matter learning Windows or Linux operating system, their underlying core is operating the CPU. Learning the working mode of the CPU can:

  • Helps understand basic concepts such as virtual memory and memory mapping, and provides a basis for learning memory management.

  • Help understand the mechanism and processing flow of interrupts and exceptions, and provide a basis for learning the exception handling of the system.

  • Help understand the mechanism and principle of privilege-level protection, and provide a basis for learning system rights management and access control.

  • Help understand the mechanism and scheduling algorithm of multitasking, and provide the basis for learning the process management and scheduling algorithm of the system.

CPU working mode

  1. Real Mode (Real Mode)
    Real mode is an early x86 CPU working mode, supports 16-bit pointers, can access 1MB of physical memory space, has no memory protection mechanism, and is mainly used for backward compatibility with old software.

  2. Protected Mode (Protected Mode)
    is the main working mode of x86 CPU, supports 32-bit pointers, can access 4GB virtual memory space, supports memory protection mechanism, multi-tasking and other functions, and improves the security and stability of the system.

  3. Virtual 8086 Mode (Virtual 8086 Mode)
    Virtual 8086 mode is a technology that simulates real mode in protected mode and is used to run 16-bit old software under 32-bit operating systems.

  4. Long Mode (Long Mode)
    is a working mode in the x86-64 architecture, which supports functions such as 64-bit addressing and 64-bit data processing, and can access 256TB of physical memory space. It is an extended mode based on the protected mode. .

Comparison of real mode and protected mode

  • Memory management: The memory management of the real mode is very simple, only 1MB of physical memory space can be directly addressed, and there is no virtual memory and memory protection mechanism. The protection mode can allocate an independent virtual address space for each process, realize virtual memory and memory protection, and prevent different processes from interfering with each other or accessing memory beyond the boundary.

  • Privilege-level protection: Real mode has only one privilege level, and all programs can access all memory and hardware resources. The protection mode divides system resources into different privilege levels, such as kernel mode and user mode. Sensitive system resources can only be accessed in the kernel mode, while restricted resources can only be accessed in the user mode. This privilege-level protection prevents illegal access and modification of system resources by processes or applications.

  • Interrupt and exception handling: The real mode has only one interrupt handling mechanism, all interrupts will be responded by the CPU, and different interrupts cannot be prioritized and processed. The protection mode provides a variety of interrupt and exception handling mechanisms, which can detect and handle application errors and exceptions, and prevent system crashes or errors.

  • Scalability: The address bus in real mode has only 20 bits, and the addressable physical memory space is only 1MB, which cannot meet the needs of today's computer systems. The address bus in protected mode can support 32-bit or 64-bit, and can address a larger physical memory space to meet the needs of modern computer systems.

Guess you like

Origin blog.csdn.net/weixin_43074760/article/details/131739674