duminică, 8 mai 2011

How do memory and prosessor work

Your computer uses the memory to storage temporary data that is used by different programs running in the background or on your main screen. It does so, because the CPU (central processing unit) can never run more than 1 program at any given time (unless of course, you have more than 1 CPU, but the point remains) and there are like 100 different services running in the background even on an idle computer.
So, in this case, the CPU executes one or two instructions for one service, than dumps down all the info for said service in the memory, where it stays cozy till the CPU has the chance to go back to it.

here is an example.
let's say the CPU (with 1 core for the sake of argument) has to run these 2 programs in the same time.
Both programs are a series of mathematical calculations:
A) (3+4+8)*7/8 - 45
B) 5*3/6/*3*4*6

so, the CPU goes to to program A and execute the first instruction. that is 3+4 (=7)
now it copy's the state of A in the RAM. now A looks like this:
(7+8)*7/8 - 45

then the CPU goes to B and execute the first instruction
15/6*3*4*6

then it copy's it in the RAM and goes back to A, and executes the next instruction.
15*7/8 -45
then copy's it again the RAM(in the place where it used to be) and goes back to B and so on and so on till the both programs are finished.

when the information from A and B are no longer needed, the results are erased, the memory is freed, and ready to take on another block on information.

Windows services, however, are looping. They never end, because if they do, your OS will stop working. So the CPU always does something, probably over and over and over again, just to keep the OS going.
Most processors now have several cores or CPUs, which makes then great for multi tasking.

Niciun comentariu:

Trimiteți un comentariu