Python learns the first day----computer basics

Source: Internet
Author: User
Tags time and date volatile

First, the purpose of Learning Computer Foundation

The advanced programming languages are all running on the operating system, and the operating system is running on the hardware basis. So before you begin to learn programming, you need to understand and know the basics of computers. Includes hardware fundamentals and operating system fundamentals.


II. History of computer hardware

The definition of computer: It is an electronic computer which is used for high-speed computation, can be calculated numerically, can be calculated logically, and has memory function.

History:

Prototypes or inspirations originated in China.

On Valentine's Day, February 14, 1946, the world's first computer, electronic digital integrator, ENIAC, was unveiled at the University of Pennsylvania.

Electron Age---transistor ERA------large scale vlsi in the era of IC

Third, the composition of the computer

Hardware system composition: arithmetic, controller, memory, input device, output device

Hardware system---Operating system---application software

The operating system is also a system software, used to control and coordinate the computer and external equipment, application software is such as QQ, World of Warcraft and other such software.


Iv. Introduction of computer hardware

CPU, memory, video monitor, keyboard controller, USB controller, hard disk controller, and monitor, keyboard, mouse, hard disk, sound card, video card, etc. all belong to the computer hardware.

1.CPU

CPU is responsible for computing, memory and hard disk is responsible for storing information, mouse keyboard used to input instructions to the computer, display for output operation information.

The CPU takes instructions from memory-"decode-" executes, and then repeats the operation, each CPU has its own set of instruction sets, the CPU of the different architectures cannot run programs that do not support this instruction set.

About the concept of registers:

Register Classification: Universal registers (for saving variables and temporary results), program counters (where the logger executes), stack pointers (advanced out, and queue exactly the opposite), program Status Word register (a very important register that contains CPU priority, CPU mode, and other control bits)

The CPU has two modes: the user state and the kernel state, when the kernel state, the CPU can execute all instructions, also means that it can dispatch the hardware, but in the user state can only execute part of the instruction set, that is not enough to dispatch the hardware. The switchover before the user state and the kernel state is implemented by "system call".

Multi-threaded and multi-core chip: The CPU has L1, L2, L3 various caches, the production of the cache material is the same as the CPU material, so the CPU access to the cache without delay. To enhance CPU performance, Intel has put forward the concept of multithreading, where the process is a resource unit and the thread is the executing unit of the CPU.

2. Memory

The ideal memory is, of course, fast-capacity and cheap, but the current level of technological development is impossible.

Memory is about the following: register, cache, memory, hard disk, tape, from the front to the back basically is the speed is more and more slow, the capacity is bigger, the volume is also bigger and larger. The L1 cache is a register in a 32-bit system with a size of 32*32 and 64*64 in a 64-bit system, as fast as the CPU . Cache is L2, when a program needs to read a storage word, the cache hardware check whether the cache line is in the cache, if so, is called a cache hit, otherwise known as a cache miss, this time to go in memory to read data.

Main Memory: That is, ram, power loss. ROM is non-volatile random access storage, EEPROM is an electrically erasable ROM is non-volatile. CMOS: Volatile, can store time and date, some other hardware configuration parameters, startup disk and other information, usually a piece of battery power, located on the motherboard.

Hard disk: Determine the hard disk two indicators, one is the speed, one is capacity. 8 BIT=1BYTES,1024BYTES=1KB,1024K=1MB,1024MB=1GB, so what we call disk capacity ultimately refers to how many 2 binary bits the disk can write . hard disks are stacked from many platters, with a tray in the middle and a robotic arm, each with a head. The value of a sector is 512 bytes, and in a Linux system, data is stored in block blocks. Eight sectors formed a block, or 4KB. The data is stored in a segment of the sector, that is, a small circle of the circle of the track, from the disk to read a piece of data need to experience the seek time and delay time , seek time is the robot arm find the track of the data, the delay time is the magnetic head on the track to find the average time required data.

Virtual Memory: According to the actual situation, the computer's memory at some point is obviously not enough to meet the requirements of large programs, such as the physical memory size is 2G, and then there is a 8G program needs to run, Then the computer needs to find the corresponding piece of the hard disk and divide it into virtual memory through the memory management unit MMU. The swap partition of a Linux system is actually virtual memory.

context switching: Switching from one program to another can improve the performance of the system.

Tape: Large capacity, often used for large database system backup

I/O devices: Includes the device controller and the device itself, each with a device controller in place where the hardware is plugged in.

Bus: 650) this.width=650; "Src=" Https://s2.51cto.com/wyfs02/M02/8E/83/wKiom1jCcoiABnFjAAIHHgd2Qvk684.png-wh_ 500x0-wm_3-wmp_4-s_1580744704.png "title=" bus. png "alt=" wkiom1jccoiabnfjaaihhgd2qvk684.png-wh_50 "/>

North Bridge is connected to such as: Cache, CPU, memory and other high-speed equipment

South Bridge is connected to such as: Hard disk, video card, USB device, sound card and other low-speed equipment

V. Computer startup process

First step: Power on

Step two: Run the BIOS to detect CPU, memory, hard disk, etc.

Step three: Read the information in the CMOS, including hardware configuration information and system boot Disk selection

Fourth step: Read the first sector of the No. 0 track of the boot disk, that is, MBR (Master boot record), a total of 512 bytes, the first 446 bytes is the boot information, the middle 64 bytes is the partition information, the last 2 bytes is the flag bit

Fifth step: Start the operating system by reading the appropriate boot module according to the MBR

Sixth step: This time the operating system asks the BIOS, obtains the configuration information and the hardware information, and detects its driver's existence, if does not prompt installs, if has the driver, the operating system then moves them into the memory to run, then creates the corresponding process, runs the graphical user interface. At this point, the computer starts to complete.

Attached: Linux boot process

First Step-load BIOS

When you turn on the computer, the computer loads the BIOS information first, and the BIOS information is so important that the computer must find it at the very beginning. This is because the BIOS contains information about the CPU, device boot sequence information, hard disk information, memory information, clock information, PNP features, and so on. After that, the computer has a spectrum and knows which hardware device to read.

Step Two--read the MBR

As we all know, the first sector of the No. 0 track on the hard disk is called the MBR, that is, the master boot record, which is the master boot records, it is 512 bytes in size, although the place is not small, but it is stored in the pre-boot information, partition table information.

When the system locates the MBR of the hard disk specified by the BIOS, it is copied to the physical memory where the 0X7C00 address resides. Actually the content that is copied to the physical memory is boot Loader, and specifically to your computer, that is LILO or grub.

Step three--boot Loader/grup

Boot Loader is a small program that runs before the operating system kernel runs. Through this small program, we can initialize the hardware device, set up a map of the memory space, so as to bring the system's hardware and software environment to a suitable state, in order to finally call the operating system kernel ready to do everything.

Boot Loader is available in several ways, including Grub, Lilo, and Spfdisk, which are common loader.

Let's take grub as an example to explain, after all, there are not many people with Lilo and Spfdisk.

The system reads the GRUB configuration information in memory (typically menu.lst or grub.lst) and launches a different operating system according to this configuration information.

Fourth Step-loading the kernel

Based on the path of the kernel image set by grub, the system reads the memory image and does the decompression operation. At this point, the screen will generally output "uncompressing Linux" prompt. When the decompression core is complete, the screen output "ok,booting the kernel".

The system places the extracted kernel in memory and calls the Start_kernel () function to start a series of initialization functions and initialize the various devices to complete the Linux core environment. At this point, the Linux kernel has been established, Linux-based programs should be able to run properly.

The fifth step--user layer Init according to the Inittab file to set the operating level

After the kernel is loaded, the first program to run is/sbin/init, which reads the/etc/inittab file and initializes it based on the file.

In fact, the main function of the/etc/inittab file is to set the Linux operating level, which is set in the form of ": Id:5:initdefault:", which indicates that Linux needs to run on level 5. Linux runs at the following levels:

0: Turn off the machine

1: Single-user mode

2: Multi-user mode with no network support

3: Multi-user mode with network support

4: reserved, not used

5: Multi-user mode with network support with X-window support

6: Reboot the system, that is, restart

There is a lot of learning about/etc/inittab documents.

Sixth step--init Process Execution Rc.sysinit

After setting the operating level, the Linux system executes the first user layer file is the/etc/rc.d/rc.sysinit script, it does a lot of work, including setting path, setting the network configuration (/etc/sysconfig/network), Start swap partitions, set/proc, and so on. If you are interested, you can go to the/ETC/RC.D to see the Rc.sysinit file, inside the script enough to see you for a few days.

Start the seventh step--Start the kernel module

The kernel modules are loaded according to the files in the/etc/modules.conf file or the/ETC/MODULES.D directory.

Starting step eighth-executing scripts with different runlevel (/ETC/RC.D/RC $RUNLEVEL # $RUNLEVEL default run mode)

Depending on the runlevel, the system will run the appropriate script from RC0.D to RC6.D to perform the appropriate initialization and start the appropriate service.

Nineth Step--Execute/etc/rc.d/rc.local

If you open this file, there is a word, read it, you will be the role of this command at a glance:

# This script would beexecuted *after* all the other init scripts.
# can put your own initialization stuff in here if you don ' t
# want to does the full Sys V style init stuff.

Rc.local is the place where Linux is left to the user to personalize after all initialization work. You can put the things you want to set up and start up here.

Tenth Step-Execute/bin/login program, enter login status

At this time, the system has entered the waiting for the user input username and password, you can already use your own account login system.


Python learns the first day----computer basics

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.