This article reprinted address : http://www.cnblogs.com/zuoxiaolong/p/computer3.html
Last chapter LZ show you the simple implementation of the Hello program, you can see in this process, the system in the transmission of data to spend a lot of time. In order to reduce the time cost of this data transmission, hardware developers adopt a caching technology to reduce this time cost.
The cache is placed in the processor, and the processor in the register file directly for data exchange, which greatly reduces the time cost of data transmission, so that the program can be run at several times the speed of ascension. And as a program ape, if you can properly use the cache to store some of the programs that may be used in the process of running data, you can increase the speed of the program several times or even several orders of magnitude.
The importance of the cache is thus visible, showing the location of the cache in the hardware distribution.
Pyramid of storage devices
In today's computer systems, basically all of them are placed into a variety of storage devices, these storage devices are clearly hierarchical structure, they are characterized by the larger the capacity, the slower the speed. So if they are presented graphically in terms of capacity and speed, they look like a pyramid, as shown below.
However, this figure is English version, LZ slightly explained, some particularly obvious LZ does not explain, if there is any ape friends really do not understand, you can go to the LZ group to ask questions.
On the left, it means smaller, faster, more expensive storage devices, including registers and L1-L3 caches, and larger, slower, cheaper storage devices, including main memory, local disks, and Remote storage devices. In general, we use the previous layer of storage as the cache for the current storage device, such as the L1 cache is a register, the L2 cache is L1, and so on.
the operating system is the hardware manager
The operating system is the software that helps us manipulate the hardware, it is like the middle of the application and the hardware, in between the two play a coordinated, management role. Their relationship is like.
The operating system provides several concepts that we are familiar with to represent hardware devices, such as processes, virtual storage, and files. They represent the hardware device as shown in.
It can be seen that the file is an abstract description of the I/O device, while the virtual memory is a generic term for main memory and I/O devices, and finally, a process is added to the processor on this basis.
Process
A process is an abstraction of an operating system to a running program . The operating system records the state of each process, which is referred to as the context of the process. These states mainly include the current contents of the PC, register, and main memory. When the operating system switches between processes, the corresponding context is also toggled to ensure that the process reverts to its previous state.
In the process, the concept of threading is introduced by the great Gods of the computer world, which can share process-level code and data, which is generally more efficient than sharing between processes.
Virtual Memory
virtual Memory is an abstract description that, physically, contains I/O devices and main memory. Logically, virtual memory is described as a virtual address space . Represents the virtual address space for the process.
Here the address from the bottom up in turn, you can see that the start address is marked in the figure, respectively, 0x08048000 (32-bit) and 0x00400000 (64-bit), and then up is read-only code and data, read and write data, runtime heap, shared library memory map interval, The user stack and the kernel virtual memory area .
After reading this figure, the LZ has a question, that is, the two 32-bit and 64-bit starting address is from where, so a little simple to explore a bit.
LZ on a 32-bit Linux system to do a test, we casually write a C program, and then use gcc plus parameter-wl,--verbose to compile the file, so we can see in the linker script. As shown in.
In the inside we can see 0x08048000 this memory address, __executable_start surface meaning is the starting position of the executable. The exact number of the reason LZ did not find, we can first save this question, perhaps in the book behind the content will answer this question. (Tip: Some things do not understand, do not indulge in this, will outweigh the gains)
From this address up, the approximate five storage areas are divided.
program code and Data : The starting address of the content is 0x08048000, first the code, then the global variables.
Heap : is a part of the memory area that can be dynamically extended by the runtime and can be manipulated by standard library functions such as malloc and free.
shared libraries : code and data that are used to hold shared libraries.
Stack : At the top of the user's virtual address space is the stack, and this part of the area is closely related to the execution of the function.
Kernel Virtual Storage area : The kernel is part of the operating system, on the LZ superficial understanding, the kernel can also be seen as a process, it is always running during the computer operation, so this part of the memory area of the user program is not visible, popular say is not used.
file
A file is a logical concept of I/O devices, which is actually a sequence of bytes, that is, some information consisting of 1 and 0. So all I/O devices, including disks, keyboards, mice, and monitors, can be viewed as files.
Network
As I said earlier, all I/O devices are actually the concrete manifestation of the abstract concept of files, so the network is also a kind of file, because in the final analysis, it can also be regarded as a series of byte sequences. The role of a network adapter is to give the computer a bunch of sent bytes, which may include pictures, text, or even code.
Article Summary
This article mainly introduces the level of storage devices and the operating system of three abstract concepts, the next chapter is a simple introduction of concurrency and parallelism, but also the last chapter of computer introduction.
Deep understanding of computer systems (1.3)---abstract concepts of pyramid-shaped storage devices and operating systems