11/2/14

Memory Swapping.

Using more of memory, as well as using faster memory can prevent computers' instability & slowness to great extent.


To be able to run a computer program, Operating System must load it into memory first (into Processor's Cache or RAM).

Running program is called a 'Process'.

What if computer memory runs out, for example: due to loading too much of data?

There's an option of using slower memory that is cheaper & loading extra data or processess as neccessary into fast memory.

For example:

1. Few processes in RAM (Random Access Memory), rest waiting to be loaded in HDD Storage or DVD-ROM.
2. A process in Cache, rest of processes in RAM & HDD Storage.
3. In case of Stitie Space, part of Stitie Machine's State & keys in fast memory, rest in slower. Strategy in either, but during code's execution - in fast memory, at least it's part.

Let's note that Memory such as Cache is closer to Processor & faster than RAM, but more expensive - therefore we can buy it less for our money. It has to be used wisely, for example for most critical & most often used parts of software.

Similarly RAM is faster & more expensive than HDD Storage.

Registers, Cache, RAM, HDD Storage & similar can form a 'Pyramid of Needs', with more rare types of memory used more sparingly, due to costs.


Smaller processes run faster - we do not need to worry too much about loading parts of the process & data, then swapping the rest as needed. In case of Cache, with execution code & data being closer to processor, requests do not need to go via Serial Bus - and that speeds computing significiantly. Similar mechanism can be observed between accessibility of RAM & HDD Storage.


Also, there are algorithms that can take advantage of extra memory to use it for faster programs' execution (for example, by storing partial results for different data sets then using them later without computing again).


With more of processes running at once there's need to do more of swapping between faster & slower memory which costs time, same with amount of data increasing.

Extreme case of swapping abuse (for example: by loading too many programs at once into memory) can halt the computer almost to zero speed or even cause Operating System to crash.... if swapping requires more effort than is used to compute processes' data.


Sources: my partial education (see [7]), 12.

No comments:

Post a Comment