Memory refers to a device in electronic circuits that records data, state, or instructions.
It is categorized into different types based on speed, volatility, and capacity:
1. Register
- Located inside the CPU — smallest and fastest memory.
- Volatile
- Fastest speed
- Smallest storage capacity
2. *Cache
- Refers to L1, L2 cache.
- Volatile
- Very fast speed
- Small storage capacity
3. Main Memory
- Typically refers to RAM.
- Volatile
- Moderate speed
- Moderate storage capacity
4. Secondary Storage
- Includes HDD, SSD.
- Non-volatile
- Slowest speed
- Largest storage capacity
Detail about *cache
The word cache is derived from the French word cacher, meaning "to hide," and refers to a place used to temporarily store or keep things.
Cache is
- A temporary storage where data is pre-copied,
- And a type of memory used to reduce bottlenecks caused by speed differences between fast and slow devices.
In practice, the speed gap between memory and CPU is very large,
so a register layer is placed in between to solve this speed difference.
The caching layer is the layer between such memory hierarchy layers designed to solve the speed gap.
Bottleneck Flow
- The CPU constantly exchanges data with memory to process data.
- The memory cannot keep up with the CPU's data processing speed.
- This causes a bottleneck where the CPU must wait for memory.
To mitigate this bottleneck, a small but fast cache memory is placed between the CPU and the main memory.
It stores copies of data expected to be reused soon, allowing the CPU to access requested data immediately.
However, cache memory is expensive to use in large capacity or as main memory.
Main memory typically uses DRAM, while cache memory uses SRAM.
SRAM cells have more transistors and occupy more physical space.
Purpose of Memory Hierarchy
The goal is to use caching to combine small, fast memory with large, slow memory so they behave like a large, fast memory.
How do we know which data is likely to be reused?
We use the principle of data locality:
- Data access happens close together in time (temporal locality) or space (spatial locality).
- A variable referenced once is likely to be referenced again shortly after.
- When accessing certain data, nearby data is also likely to be accessed.
Important Note
Because caching uses copies of data, differences between the copy and original may occur. Maintaining consistency is important.
Conclusion
Caching stores copies of data or computed results to improve overall processing speed when:
- Direct access to data takes a long time,
- You want to skip recalculating needed values,
- The same results are repeatedly returned (e.g., images or thumbnails).
'Computer Science > Operating System' 카테고리의 다른 글
Process (0) | 2025.07.30 |
---|---|
How memory manages data (0) | 2025.07.27 |
Components of a computer (0) | 2025.07.22 |
Structure of the Operating System (0) | 2025.07.19 |
What is an operating system? (0) | 2025.07.16 |