Python programming basics-hardware basics of computer principles and python programming Basics

Source: Internet
Author: User
Tags amd processors

Python programming basics-hardware basics of computer principles and python programming Basics

I. registers: registers are some small storage areas used inside the CPU to store data, and are used to temporarily store data and calculation results involved in calculation.

1. register features:

1) registers are located inside the CPU. The number is very small. There are only fourteen registers;

2) the data that registers can store is not necessarily 8 bits, some registers can store 16 bits of data, and some registers in the 386/486 processor can store 32 bits of data;

3) Each internal register has a name without an address number similar to the memory.

2. Register Classification:

1) Data Register: The data register is mainly used to save information such as the operands and operation results, thus saving the time required to read the operands to occupy the bus and access the memory.

2) address change register: it is mainly used to store the offset of the storage unit in the segment. It can be used to address multiple storage operations and provide convenience for accessing the storage unit in different addresses. The address change register cannot be divided into eight-bit registers. As a general-purpose register, you can also store the operands and results of arithmetic logic operations. They can be used as general memory pointers. In the execution of string operation commands, they have specific requirements and special features.

3) pointer register: it is mainly used to store the offset of the storage unit in the stack. It can be used to address multiple storage operations and provide convenience for accessing the storage unit in different addresses. Pointer registers cannot be divided into eight-bit registers. As a general-purpose register, you can also store the operands and results of arithmetic logic operations. It is also called a stack pointer register.

4) segment register: the segment register is set based on the memory segment management mode. The physical address of a memory unit is composed of the block register value and an offset, so that two smaller-digit values can be combined into a memory address that can access a larger physical space.

5) State Register: used to store two types of information: one is various state information that reflects the execution result of the current command, such as carrying (CY bit) and overflow (OV bit ), the result is positive or negative (SF bit), the result is zero (ZF bit), the parity sign (P bit), and so on; the other is to store control information, such as the allowed interruption (if bit ), trace flag (TF bit) and so on. In some machines, PSW is called the Flag Register ).

 

 

Ii. Evolution of processor design:

1. Initially: Values, decoding, and execution are performed in three steps at the same time. This means that each step has to wait for the execution results of other steps, which is a waste of time and resources.

2. Later: Value Unit ------> decoding unit -------> Execution Unit, which is a three-step pipeline design. That is, when the value is N, it can be decoded by N + 1 or N + 2.

3. Super variable CPU, which is more advanced than the pipeline CPU, can execute multiple units at the same time, similar to the simultaneous execution of multiple pipelines;

 

Iii. kernel mode and user mode:

1. kernel state: when the program is running in kernel state, the CPU can execute all the commands in the instruction set, including the functions available in hardware.

2. User State: when a program is running in user State, only one instruction set of the CPU can be executed and hardware cannot be operated directly. Therefore, generally, user-State processes cannot occupy I/O and memory protection by other programs. Of course, they cannot modify the program status in the program status word register.

 

4. Switch between kernel mode and user mode:

1. When a system call occurs

This is a way for a user-state process to actively request to switch to the kernel state. User-State processes apply to use the system call service routines provided by the operating system to process tasks through system calls. The core of the system calling mechanism is the interrupt mechanism specially developed by the operating system for users, that is, Soft Interrupt.

2. Exceptions

Some unknown exceptions occur when the CPU runs a program in the user State. In this case, the running process is triggered to switch to the kernel-related program that handles the exception, that is, it is switched to the kernel State. If a page is missing, an exception occurs.

3. When peripherals are interrupted

After the peripheral device completes the user request, it sends an interrupt signal to the CPU, at this time, the CPU will suspend the execution of the next command to be executed and then execute the processing program corresponding to the interrupt signal. If the previously executed command is a user-State program, the conversion process naturally changes from user to kernel. For example, after the hard disk read/write operation is completed, the system switches to the hard disk read/write Interrupt Processing Program for subsequent operations.

 

V. Storage

1. registers: registers are integrated into the CPU. They use the same material as the CPU, which is the fastest, but the cost is also the most expensive. All spaces are small, <1 KB

2. Advanced cache: L1 (level-1 cache), L2 (level-2 cache), and L3 (level-3 cache), which are temporary memory located between CPU and memory, its capacity is smaller than the memory but the switching speed is faster. The data in the cache is a small part of the memory, but this small part is about to be accessed by the CPU in a short time. When the CPU calls a large amount of data, you can avoid calling the memory directly from the cache to speed up reading. Initially, the CACHE is only level 1, and level 2 CACHE appears to coordinate the speed between Level 1 CACHE and memory. The second-level cache is slower than the first-level cache and has a larger capacity. It is mainly used for temporary data exchange between the first-level cache and the memory. In fact, Intel and AMD processors have different logical structure designs for level-1 caching, so the impact of level-2 caching on CPU performance is also different.

3. Memory: a bridge between memory and CPU. All programs run in the memory, including the operating system itself. The function is to temporarily store computing data in the CPU, as well as data exchange with external storage, the memory size and frequency also affect the overall computing performance. The memory is a random storage and data loss caused by power outages.

4. ROM: Read-Only storage, which is written to the required program during manufacturing. It is read-only and cannot be modified, and will not be lost due to power failure, such as the BIOS of a computer.

5. CMOS: used to store computing time information, BIOS configuration parameters, and other information, resulting in loss of power-off data.

6. External Storage: external storage, including hard disks and high-speed flash memory, is mainly used to store data without data loss due to power failure. The computer operating system is installed in external storage.

 

Vi. Disk

Disks are also a type of storage, which stores user data, operating systems, and installed applications.

 

1. Disk Surface

Hard Disk disks are generally made of aluminum alloy materials as substrates, and high-speed hard disks may also be made of glass as substrates. Each disk on a hard disk has two sides, that is, the top and bottom sides. Generally, each Side can be used to store data and become a valid disk, there are also a few hard disk faces that are singular

 

2. Track

The disk is divided into many concentric circles during formatting. These concentric circle tracks are called tracks ). The track starts from 0 in sequence. Each disk on the hard disk has 300 ~ 1 024 channels, with more tracks on each side of the new large-capacity hard drive. Information is recorded in these tracks in the form of a pulse string. These concentric circles are not continuously recorded data, but are divided into arcs in the middle segment. These ARCs share the same angular velocity. Because the radial length is different.

 

 

3. cylinder (number of cylinders = number of tracks)

A Cylinder is a Cylinder formed by the same track on all disks. The head of each Cylinder starts from "0" from top to bottom. The read/write operations are performed by the cylinder. That is, when the head reads/writes data, the operation starts from the "0" head in the same cylinder, in turn, the operation is performed on different disks of the same cylinder, that is, the head is transferred to the next cylinder only after all the heads of the same cylinder have been read/written, because the selected head only needs to be switched electronically, and the selected cylinder must be switched mechanically.

4. Sector

The operating system stores information on the hard disk in the form of a Sector (Sector). Each Sector is 512 bytes. One slice has two main parts: the identifier of the location where the data is stored and the data segment where the data is stored. Data is stored on individual sectors.

 

When the system stores files on a disk, it uses the cylindrical, Head, and sector method, that is, the first Magnetic Head of the 1st track (that is, the first Magnetic Track of the 1st disk) and then the next head of the same cylinder ,......, After a cylindrical storage is full, it is pushed to the next cylindrical until all the file content is written to the disk.

The system also reads data in the same order. When reading data, the disk controller is notified to read the cylindrical number, head number, and fan area number of the slice (three parts of the physical address. The disk controller directly moves the head parts to the corresponding cylinder, selects the corresponding head, and waits for the required sector to move to the bottom of the head. Therefore, when reading and reading data, there is a tracing time and a delay time.

5. Average track time: the time when the head moves from one cylinder to another;

6. Delay Time: After the head is moved to the track, it must wait until it is rotated to the data area. This time is called the delay time.

7. Virtual Memory: virtual memory is a storage space used for memory in the hard disk of a computer.

 

VII. Computer Startup Process

1. Power on the computer.

2. Load the BIOS and check the hardware.

3. Load CMOS and find the Startup Device Based on the settings in CMOS.

4. Read the content of the first sector from the boot device according to the boot sequence (one sector is 512 bytes, and the first sector contains: The first 446 bytes are MBR, that is, the Master Boot Record, 64-byte disk partition table, 2 bytes reserved)

5. Read the bootloader according to the Master Boot Record and the disk partition table, start the loading module, and start the operating system.

6. The operating system loads the Driver Based on the BIOS information. All the drivers are loaded into the kernel. Finally, some self-started applications and some internal system tables are started.

 

 

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.