当前位置:网站首页>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 !
边栏推荐
- Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
- 0-1背包問題(一)
- 【高老师UML软件建模基础】20级云班课习题答案合集
- 渗透测试 ( 7 ) --- 漏洞扫描工具 Nessus
- China chart recorder market trend report, technology dynamic innovation and market forecast
- Analysis of protobuf format of real-time barrage and historical barrage at station B
- 渗透测试 2 --- XSS、CSRF、文件上传、文件包含、反序列化漏洞
- nodejs爬虫
- Research Report of cylindrical grinder industry - market status analysis and development prospect forecast
- The most complete programming language online API document
猜你喜欢

信息安全-威胁检测-flink广播流BroadcastState双流合并应用在过滤安全日志

Information security - threat detection engine - common rule engine base performance comparison
Frida hook so layer, protobuf data analysis

Record of force deduction and question brushing

信息安全-安全编排自动化与响应 (SOAR) 技术解析

B - Code Party (girls' competition)

C语言数组的概念
![[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class](/img/57/bc6eda91f7263acda38b9ee8732318.png)
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class

Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability

B - 代码派对(女生赛)
随机推荐
Gartner:关于零信任网络访问最佳实践的五个建议
Information security - security professional name | CVE | rce | POC | Vul | 0day
X-forwarded-for details, how to get the client IP
STM32 learning record: LED light flashes (register version)
[exercise -11] 4 values why sum is 0 (and 4 values of 0)
Opencv learning log 13 corrosion, expansion, opening and closing operations
Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
Information security - threat detection - Flink broadcast stream broadcaststate dual stream merging application in filtering security logs
Perinatal Software Industry Research Report - market status analysis and development prospect forecast
The most complete programming language online API document
数据在内存中的存储&载入内存,让程序运行起来
[teacher Gao UML software modeling foundation] collection of exercises and answers for level 20 cloud class
E. Breaking the Wall
Penetration test 2 --- XSS, CSRF, file upload, file inclusion, deserialization vulnerability
渗透测试 ( 3 ) --- Metasploit Framework ( MSF )
[exercise-6] (UVA 725) division = = violence
7-1 understand everything (20 points)
【练习-2】(Uva 712) S-Trees (S树)
Web based photo digital printing website
想应聘程序员,您的简历就该这样写【精华总结】