Home > other >  Why do the program runs need memory?
Why do the program runs need memory?

Time:09-24

A computer program
=code + dataWhat is the code?
Code is the function, the function is the code, but no he
What is data?
Data we define global variables, local variables, etc., as long as everything is handled by code as data,
Code and the data relationship is as close as lips and teeth, together constitute the computer program, a computer program without data almost does not exist, even if there is, the function of the implementation is also negligible, in this may have a doubt, when I printf (), print the helloworld, there is no definition of any variable, the printf () function, the function implementation rely mainly on vsprintf function, which defines the many variables, is known as the data, we did not define variables, doesn't mean it doesn't exist in our program, when we are in accordance with certain rules to data into the program constitutes a computer program
A computer program run exactly for the sake of what?
The essence of the computer program is running, the code has been carried out in succession process
Computer program operation is to get the data, get the computer can identify binary data, we are called the target data, raw data is our data to be processed, the original data after code processing, calculate the binary data can identify, the central processor CPU brain thinking is completed through the computer, the binary data line, get the same things similar to the original data, to show us, a computer program of data processing, in the final analysis is a kind of the change of the quantity, and no qualitative change, similar to, the data are water and flour, noodles machine code is the processing, flour and water after processed noodles machine processed, get our target product noodles,
A computer program run seems to has nothing to do with memory?
Actually otherwise, the memory is all programs overrepresented, no memory, you write the program can only lie on the hard disk, memory is the bole program, the program is the memory of the horse, we know that the world has bole and swift horse, no memory the bole, program a swift horse only death in the hard disk, operating system, also can't survive in Linux, Windows, MAC, android, android is the Linux kernel cutting transplantation, are running on the memory, the phone starts by ROM (norflash) norflash features: after electricity don't initialize, start the bootstrap, direct in situ run preset do simple initialization, then initialize the RAM (memory), start the boot ROM the preset program, to load the BootLoader into memory, running, and then by the Linux kernel bootLoder start... , the computer started by the BIOS, including curing start the boot code, do simple initialization, and to save memory, when after the initialization, mount system disk, loading the operating system running in the program into memory, at this point, the boot process, is the best example, 8 gb of memory, the available memory never using 8 g, the reason is that the operating system program is running on the memory, the requisition by the operating system's memory, have the right to access, not to mention the release, the operating system is a great manager, manage all of the available resources, even the operating system is to be attached to the memory and life, do you think of a computer program may be out of memory and exist independently? Clearly not reality, you may say some SCM, but some of the singlechip microcomputer function compared with the computer is a little bit small, there is no data of the function of the program implementation is negligible, also so don't need memory program, memory are overrepresented for computer programs,

CodePudding user response:

Say more clear, beginners can take a look
  • Related