Operating system condensed notes (2)-operating system structure

 Main quotes from the article notes:

Axiu’s study notes (interviewguide.cn)

Kobayashi coding (xiaolincoding.com)

Tell me about memory in your understanding? What is his role?

In a multiprogramming environment, in order to distinguish the data storage locations of each program, the operating system adopts the following main technologies and strategies:

  1. Process and address space : The operating system allocates an independent address space to each process, which is the virtual address space . The virtual address space is an address range independently owned by each process and is used to store the code, data, stack and other information of the process . The virtual address space of each process starts from 0, so the data of each program is stored in its own virtual address space and is isolated from each other.

  2. Memory paging : In order to manage memory more efficiently and achieve memory isolation between processes, the operating system uses memory paging technology . Memory is divided into equal-sized chunks called pages. Each process's virtual address space is also divided into equal-sized blocks called virtual pages. The operating system uses page tables to map virtual pages to physical pages (pages in real memory). The page table of each process is independent, so that virtual pages of different processes can be mapped to different physical pages, achieving memory isolation.

  3. Memory protection : In order to prevent processes from interfering with each other and accessing each other's data, the operating system uses a memory protection mechanism to limit each process's access to memory. In the page table, you can set the page access permissions, such as read-only, writable, executable, etc. The operating system will set page table entries based on the access rights of the process to ensure that the process can only access the memory area it owns and cannot access the memory of other processes.

  4. Process switching : In a multiprogramming environment, the CPU switches between different processes to achieve concurrent execution. When a process is scheduled for execution, the operating system loads the page table of the process into the memory management unit ( MMU ) so that the virtual address of the process can be correctly mapped to the physical address . When a process switches, the MMU switches to the page table of the next process to achieve memory isolation between processes.

Through the above technologies and strategies, the operating system can distinguish the data storage location of each program and ensure the data and memory isolation between each process, thereby realizing the concurrent execution of multi-programs. In this way, each program can run in an independent address space without interfering with each other, ensuring the stability and security of the system.

What modules does the von Neumann structure have? Which parts of modern computers do they correspond to? (Baidu is on the safe side)

  • Storage: memory
  • Controller: CPU control unit, south bridge and north bridge
  • Operator: Logical operation unit in CPU
  • Input device: keyboard
  • Output device: monitor, network card

CPU

Registers, control units and logic operation units

Common register types:

  • General-purpose registers are used to store data that need to be operated, such as two data that need to be added.
  • The program counter is used to store the "memory address" of the next instruction to be executed by the CPU. Note that it does not store the next instruction to be executed. At this time, the instruction is still in the memory. The program counter only stores the "address" of the next instruction. .
  • The instruction register is used to store the instruction currently being executed, that is, the instruction itself. The instructions are stored here before the instruction is executed.

bus

The bus is used for communication between the CPU and memory and other devices. The bus can be divided into 3 types:

  • Address bus , used to specify the memory address that the CPU will operate on;
  • Data bus , used to read and write memory data;
  • The control bus is used to send and receive signals, such as interrupts, device resets, etc. The CPU will naturally respond after receiving the signals. At this time, the control bus is also needed;

When the CPU wants to read and write memory data, it generally needs to pass the following three buses:

  • First, the memory address must be specified through the "address bus";
  • Then control the read or write commands through the "control bus";
  • Finally, the data is transmitted through the "data bus";

The main difference between 32-bit and 64-bit CPUs is how many bytes of data can be calculated at one time:

  • A 32-bit CPU can calculate 4 bytes at a time;
  • A 64-bit CPU can calculate 8 bytes at a time;

Guess you like

Origin blog.csdn.net/shisniend/article/details/131863923