What is memory Hierarchy?
The Memory hierarchy is a hierarchical representation of computer memory according to some calculations such as access type, capacity, cycle time, latency, bandwidth, cost, etc. In the memory hierarchy, from top to bottom the latency and the bandwidth, capacity increase. but from bottom to top the speed and the cost per bit increase. CPU Register is the most powerful and expensive memory in the hierarchy. for more details see the image attached below.
Parameters of the memory hierarchy
Access type - The action that physically takes place during a read-write operation
Capacity - The storage size that the device has. It is measured in bytes.
Cycle time - The time elapsed from the start of a read operation to the start of a subsequent read.
Latency - The time interval between the request for information and the access to the first bit of that information.
Bandwidth - A measure of the number of bits per second that can be accessed.
Locality of Reference - A computer program tends to access memory locations that are near to each other and with a high frequency. It improves the performance of the computer. A computer system can optimize memory management and caching algorithm to reduce the number of cache misses and improve overall performance. There are 2 locality types.
Spatial Locality - The tendency of a program to access memory locations that are close to each other in space.
( ex: array - Consecutive instruction in a straight line program)
Temporal Locality - The tendency of a program to access the memory location that it has recently accessed.
( ex: loop - an instruction in a program loop )
The Average memory access time ( tav )
- The probability of finding the requested item in the first level is called the hit ratio, h1
- The probability of not finding the requested item in the first level of the memory hierarchy is called the miss ratio. ( 1 - h1 )
- If it is a miss, it will search the data in the next level of memory hierarchy.
- In the second level
miss ratio - ( 1 - h2 )
- Cache hit - If the requested items are currently in the cache.
- Cache miss - If the requested items are not in the cache.
In conclusion here we provided the complete guide for how the memory hierarchy works and how the cache memory works. Let's explore more about cache memory and data-storing methods in cache memory in the next post. 🍏🐝