当前位置:网站首页>Data storage in memory & loading into memory to make the program run
Data storage in memory & loading into memory to make the program run
2022-07-06 16:04:00 【Programming fish 66】
The information that a computer has to process is diverse , Like numbers 、 written words 、 Symbol 、 graphics 、 Audio 、 Video etc. , This information is different in people's eyes . But for computers , They are all the same in memory , All in binary form .
To learn programming , You have to understand binary , It is the basis of computer processing data .
Memory module is a very precise component , It contains hundreds of millions of electronic components , They are very small , At the nanometer level . These components , It's actually a circuit ; The voltage of the circuit will change , Or 0V, Or 5V, There are only two voltages .5V It's power on , use 1 To express ,0V It's a power outage , use 0 To express . therefore , One component has 2 States ,0 perhaps 1.
We use the circuit to control the power on and off of these components , There will be a lot of 0、1 The combination of . for example ,8 There are 28=256 Different combinations ,16 There are 216=65536 Different combinations . Although a component can only represent 2 A numerical , But a lot of values can be represented by a combination of many .
We can give each combination a specific meaning , for example , It can be used separately 1101000、00011100、11111111
To express C、 language 、 said , This a few word , So combine 1101000 00011100 11111111 It means ”C Language “
In general, we don't use components one by one , It's going to be 8 A component is a unit , Even if it means a very small number , for example 1, Also needed 8 individual , That is to say 00000001.
1 The components are called 1 The bit (Bit) or 1 position ,8 The components are called 1 byte (Byte), that 16 A component is 2Byte,32 One is 4Byte, And so on :
8×1024 A component is 1024Byte, Shorthand for 1KB;
8×1024×1024 A component is 1024KB, Shorthand for 1MB;
8×1024×1024×1024 A component is 1024MB, Shorthand for 1GB.
Now? , You know, 1GB How many components do you have in your memory . What we usually call the file size KB、 How many? MB, That's what it means .
Unit conversion :
- 1Byte = 8 Bit
- 1KB = 1024Byte = 210Byte
- 1MB = 1024KB = 220Byte
- 1GB = 1024MB = 230Byte
- 1TB = 1024GB = 240Byte
- 1PB = 1024TB = 250Byte
- 1EB = 1024PB = 260Byte
When we usually use computers , Usually it's only designed to KB、MB、GB、TB These units ,PB and EB These two advanced units are generally used in the process of big data processing .
You see , There is no... In memory abc Such characters , either gif、jpg Such a picture , Only 0 and 1 Two figures , Computers only know 0 and 1. therefore , Computers use binary , Not the familiar decimal system , Data written to memory , Will be converted to 0 and 1 The combination of .
Programmer's humor
To impress , Finally, let's see a joke .
The programmer A:“ cronies , I'm short of money recently , Borrow some money ?”
The programmer B:“ Yes , How many do you want? ?”
The programmer A:“ A thousand lines No ?”
The programmer B:“ Who are we with ! I'll round it up for you ,1024, Take it .”
Do you understand the joke ? Please choose the right answer .
A) Because he sympathizes with programmers A, Give him more 24 block
B) This programmer can't count , Maybe it's too poor and hungry
C) This programmer intentionally , Because his dictatorial wife rules 1024 Is an integer
D) It's like 100 yes 10 To the power of an integer ,1024 yes 2 Integer power of , For programmers, it's integers
Study with the webmaster , Every day there is progress .
Easy to understand , Explain profound theories in simple language , An article only talks about one point of knowledge .
The article is not abstruse , There's no need to delve into , On the bus 、 On the subway 、 You can read in the toilet , Go up anytime, anywhere .
The article does not cover code , Do not burn brain cells , Everyone can learn .
When you decide to join C Language /C++ Programming learning base :828339809, You have surpassed 90% The programmer !
Load memory , Let the program run
If you have installed QQ, You want to chat with your friends , Double click QQ Icon , open QQ Software , Enter account number and password , Then log in .
that ,QQ How did it work ?
First , One thing you need to be clear about , You installed QQ The software is stored on the hard disk .
double-click QQ Icon , The operating system will know that you want to run this software , It will find your installation in the hard disk QQ Software , Put the data ( The software installed is essentially a collection of a lot of data ) Copy to memory . Yes ! Copy to memory !QQ Not running on a hard disk , It's running in memory .
Why? ? Because the reading and writing speed of memory is much faster than that of hard disk .
For read and write speed , Memory > Solid state disk > Mechanical drive . Mechanical hard disk drives the disk to rotate by motor to read and write data , The memory module reads and writes data through circuits , The speed of the motor must not have the transmission speed of electricity ( Almost the speed of light ) fast . Although solid state drives also read and write data through circuits , But because it is different from the control mode of memory , It's not as fast as memory .
therefore , Whether it's running QQ Or editor Word file , First copy the data on the hard disk to the memory , To make CPU To deal with it , This process is called loading memory (Load into Memory). This process requires a special program ( Software ), This program is called loader (Loader).
CPU Dealing directly with memory , It reads the data in memory for processing , And save the results to memory . If you need to save to hard disk , Will copy the data in memory to the hard disk .
for example , open Word file , Enter some text , Although what we see is different , But the document in the hard disk has not changed , The newly added text is temporarily saved to memory ,Ctrl+S Will be saved to the hard disk . Because data will be lost after memory power failure , So if you finish editing Word If you forget to save the document, you shut down , So you'll never get it back .
Virtual memory
If we run more programs , It takes up more space than memory ( Memory module ) Capacity . For example, the memory capacity of a computer is 2G, But it's running 10 Procedures , this 10 Programs occupy a total of 3G Space , That means you need to copy from your hard drive 3G Data to memory , It's obviously impossible .
operating system (Operating System, abbreviation OS) Solved this problem for us : When the space required for program operation is greater than the memory capacity , The temporarily unused data in memory will be written back to the hard disk ; Read the data from the hard disk when you need it , And write another part of the unused data to the hard disk . such , There will be some space in the hard disk to store temporarily unused data in memory . This part of space is called virtual memory (Virtual Memory).
3G - 2G = 1G, The above situation needs to be allocated on the hard disk 1G Virtual memory .
The reading and writing speed of hard disk is much slower than that of memory , It takes a lot of time to exchange data repeatedly , So if your memory is too small , It will seriously affect the running speed of the computer , It will even appear ” stuck “ The phenomenon , Even if CPU powerful , It won't make a big difference . If economic conditions permit , It is recommended to upgrade the memory to 4G, stay win7、win8、win10 The software will run smoothly under .
More about memory , Everyone is learning 《C Language introduction tutorial 》 after , Please read on 《C Language and memory 》, I'm sure you'll have an epiphany .
summary :CPU Read data directly from memory , After processing, write the result to memory .
chart 1:CPU、 Memory 、 The relationship between hard disk and motherboard

Study with the webmaster , Every day there is progress .
Easy to understand , Explain profound theories in simple language , An article only talks about one point of knowledge .
The article is not abstruse , There's no need to delve into , On the bus 、 On the subway 、 You can read in the toilet , Go up anytime, anywhere .
The article does not cover code , Do not burn brain cells , Everyone can learn .
When you decide to join C Language /C++ Programming learning base :828339809, You have surpassed 90% The programmer !
边栏推荐
- Perinatal Software Industry Research Report - market status analysis and development prospect forecast
- Hdu-6025-prime sequence (girls' competition)
- 数据在内存中的存储&载入内存,让程序运行起来
- Research Report on shell heater industry - market status analysis and development prospect forecast
- Opencv learning log 15 count the number of solder joints and output
- 【练习4-1】Cake Distribution(分配蛋糕)
- 通俗地理解什么是编程语言
- [exercise-5] (UVA 839) not so mobile (balance)
- 差分(一维,二维,三维) 蓝桥杯三体攻击
- C语言数组的概念
猜你喜欢

X-Forwarded-For详解、如何获取到客户端IP

Information security - threat detection - detailed design of NAT log access threat detection platform
![[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class](/img/3b/dc43564a36f82e73826b08f39c935e.png)
[analysis of teacher Gao's software needs] collection of exercises and answers for level 20 cloud class

渗透测试 ( 8 ) --- Burp Suite Pro 官方文档

Penetration test (8) -- official document of burp Suite Pro

Analyse du format protobuf du rideau en temps réel et du rideau historique de la station B

Gartner: five suggestions on best practices for zero trust network access

B - Code Party (girls' competition)

Nodejs+vue网上鲜花店销售信息系统express+mysql

Matlab comprehensive exercise: application in signal and system
随机推荐
Path problem before dynamic planning
Frida hook so layer, protobuf data analysis
D - function (HDU - 6546) girls' competition
[exercise-8] (UVA 246) 10-20-30== simulation
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
基于web的照片数码冲印网站
【练习-7】(Uva 10976)Fractions Again?!(分数拆分)
China's earthwork equipment market trend report, technical dynamic innovation and market forecast
【练习-9】Zombie’s Treasure Chest
【高老师UML软件建模基础】20级云班课习题答案合集
区间和------离散化
C语言数组的概念
Research Report on market supply and demand and strategy of geosynthetics industry in China
C语言学习笔记
Nodejs crawler
Opencv learning log 30 -- histogram equalization
【练习-6】(PTA)分而治之
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
Web based photo digital printing website
Research Report on market supply and demand and strategy of China's land incineration plant industry