I guess it copies, since it is a temporary memory, it will erase if power is not supplied, so, that will lead to data loss right, but still, I need clarification.
-
1$\begingroup$ What actual benefits do you believe there could be in erasing the program (or any piece of data, really) from disk when loading it to RAM? $\endgroup$– dkaeaeCommented Jul 8, 2019 at 15:49
-
$\begingroup$ sorry, I can't get your point, do you mean it loads data? $\endgroup$– Jemuel B JerohamCommented Jul 8, 2019 at 15:51
-
1$\begingroup$ "Copying" and "loading" data are usually synonyms. $\endgroup$– dkaeaeCommented Jul 8, 2019 at 16:01
-
1$\begingroup$ oh, I thought loading is something which actually takes data from hard disk, Thankyou very much for clarifying me even though it is a silly question, thank you for spending your valuable time answering me. $\endgroup$– Jemuel B JerohamCommented Jul 8, 2019 at 16:08
3 Answers
A supplement to the earlier answers:
In modern operating systems, programs are often only partially loaded into RAM. The way it works, roughly, is that the first part of the program that is supposed to run is loaded into RAM, and then it starts running. At that point, from the point of view of the running program, all of it is available. So if the code wants to jump to a location in the code that hasn't been loaded into RAM, it tries to jump there. This causes what's known as a page fault from the operating system. The operating system notices that the program is trying to access a part of the program that does not exist in RAM, and the OS then goes and loads that part of the program from disk, places the newly loaded code somewhere in RAM, and assigns pointers so that the program can now find the code it wanted to access. This may happen repeatedly. It can allow a large program to use less RAM, making more RAM available for other things.
Ram used to load a program because ram is a volatile memory i.e. after. Power cut or after the task is over the data in ram is lost so all the data is saved in. Our hard disk Here. Copying and loading are equivalent in this case
RAM (Random Access Memory) and CPU (Central Processing Unit) both works together to execute your program which is stored on hard drive. RAM is volatile memory and its looses its contents when there is no power, that is why your program is saved on Hard Drive. Computer use RAM to store recently executed program because it is faster for CPU to read program code from RAM than Hard Drive due to speed. CPU calculate or execute program with enormous speed than Hard Disk can read or write, so RAM loads program from Hard Disk then pass to CPU for Calculations, thus speeding overall process.
-
$\begingroup$ The graph looks nice. Did you draw the graph by yourself? $\endgroup$– John L.Commented Jul 8, 2019 at 19:27