Introduction to Computer system architecture

Source: Internet
Author: User

1 Introduction

Any problem in the field of computer science can be solved by adding an indirect middle layer.

The structural structure of U-Gas turbine system is designed as follows:

Each level needs to communicate with each other, since communication is required to have a communication protocol, which is the interface. The layer below the general interface is the provider of the interface, the interface is defined by it, and the upper layer of the interface is the user of the interface, which uses the interface to implement the required functionality.

For example, from the overall hierarchy, the development tools are at the same level as the application, and they are all the interfaces that are provided by the runtime, that is, the application programming interface. The provider of the application interface is the runtime and what kind of API the runtime provides. For the operating system, the runtime is the user of the system invocation interface provided by the operating system and the operating system is the provider. The kernel layer of the operating system is the hardware interface of the user, and the hardware is the definition of the interface, the hardware interface definition determines the operating system kernel, specifically, how the driver uses the operating hardware, how to communicate with the hardware.

2 What the operating system does

One of the functions of the operating system is to provide an abstract interface, and another primary function is to manage hardware resources.

A computer's resources are primarily CPU, memory (including memory and disk), and I/O devices.

2.1 Not enough memory to do

On an earlier computer, the program was run directly on physical memory, that is, the address that the program accesses at run time is the physical address. Of course, if a computer is running only one program at a time, there will be no problem as long as the program requires no more memory than the size of the physical memory. So the obvious question is when there are multiple programs to run?

Disadvantages:

    • The address space is not isolated, all programs have direct access to physical memory, and the memory space used by the program lock is not isolated from each other.
    • Memory usage is inefficient, because there is no effective management, usually a program needs to be executed, the entire program needs to be transferred into memory.
    • The address of the program run is not deterministic. So the program needs to be loaded every time, we allocate memory from memory, but the assigned address is indeterminate.

The solution to these problems is to increase the middle tier even with a method of indirectly accessing the address. We consider the address of the program as a virtual address, and then convert the virtual address to a physical address through some mapping methods. This ensures that the address space accessed by any one program does not overlap with the other program to achieve address space isolation.

2.1.2 About Isolation

Virtual address space is virtual, people imagine the address space, in fact, it does not exist, each process has its own independent virtual address space, and each process can only access their own address space, so that the process is effectively isolated.

2.1.3 Segment

At first, people used a method called segmentation, and the basic idea was to map a virtual space of the amount of memory space required by a program to an address space. But this only solves the first and third problems, and does not solve the second problem, that is, the memory efficiency problem. Segment to the memory area of the mapping or according to the program, if the memory is not enough, swapped out to the disk is the entire program, which will inevitably result in a large number of disk access operations, mainly the granularity of fragmentation is large. Because according to the local principle of the program, at a certain time, it will only access a small amount of data, that is, the program of a lot of data will not be used, and then think of a smaller size of paging.

2.1.4 Sub-page

The basic method of paging is to divide the address space into fixed-size pages, each page size is determined by the hardware, or the hardware supports multiple-size pages, and the operating system chooses to determine the size of the page.

For example, as shown, each virtual space has 8 pages with a size of 1KB per page, so the virtual address space is 8KB. Assuming that there is 6KB of memory, then the physical space actually really works just before 6KB.

Then, we divide the virtual address space of the process into pages, load the common data and code pages into memory, store the infrequently used code and data on the disk, and then remove it from the disk when needed. We assume that there are two processes Process1 and process2, and that some of the virtual pages in the process are mapped to physical pages, such as VP0, VP1, and VP7 mapped to PP0, PP2, and PP3, while some of the pages are on disk, such as VP2 and VP3 in disk DP0 and DP1 Another page, such as VP4, VP5, and VP6, may not have been used or accessed, and they are temporarily in an unused state. Here, we refer to the Virtual Space page as the virtual page (VP), the physical memory of the page is called the physical page (PP), the disk page is called the disk page (DP).

Process1 's VP2 and VP3 are not in memory, but when the two pages are accessed, the hardware captures the message, the so-called page fault, and the operating system takes over the process and is responsible for reading the VP2 and VP3 from the disk and loading the memory. The page table is then updated with the mapping between the two pages in memory and VP2 and VP3.

However, if you access Process1 's VP5 and VP6, a segment error occurs (because the two pages are not mapped).

Protection is also one of the purposes of mapping, simply to say that each page can be set permissions properties, who can modify, who can access and so on.

The implementation of virtual storage requires hardware support and is different for different CPUs, but almost all of the hardware is mapped using a part called MMU. :

In page mode, the CPU sends out the virtual address, which is what we're seeing. Converted to physical Address via MMU.

Introduction to Computer system architecture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.