Tải bản đầy đủ (.docx) (13 trang)

C5P1 cache memory principles

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (723.43 KB, 13 trang )

<span class="text_page_counter">Trang 1</span><div class="page_container" data-page="1">

<b>5.1 Cache Memory Principles</b>

<b>Cache Memory is a special very high-speed, small memory that stores data so </b>

that future requests for that data can be served faster. The cache contains a copy of portions of the main memory.

<b>Cache operates as a turbocharger to slower main memory by holding copies of code </b>

and data that are frequently requested from the main system memory by the microprocessor.

 Characteristics of Cache Memory (Optional)

 Cache memory is an extremely fast memory type that acts as a buffer between RAM and the CPU.

 Cache Memory holds frequently requested data and instructions so that they areimmediately available to the CPU when needed.

 Cache memory is costlier than main memory or disk memory but more economical than CPU registers.

 Cache Memory is used to speed up and synchronize with a high-speed CPU.

<b>Levels of Memory</b>

<small></small> <b>Level 1 or Register (CPU): It is a type of memory in </b>

which data is stored and accepted that are immediately stored in the CPU. The most commonly used register is Accumulator, Program counter, Address Register, etc.

<small></small> <b>Level 2 or Cache memory (L1, L2, L3): It is the fastest </b>

memory that has faster access time where data is temporarily stored for faster access.

<small></small> <b>Level 3 or Main Memory (RAM): It is the memory on </b>

which the computer works currently. It is small in size and once power is off data no longer stays in this memory.

<small></small> <b>Level 4 or Secondary Memory (Hard disk) : It is </b>

external memory that is not as fast as the main memory Slow

Word

transfer Fast<sup>Block </sup>transfer

</div><span class="text_page_counter">Trang 2</span><div class="page_container" data-page="2">

<b>Cache/Memory Structure</b>

 <i>Block: The minimum unit of transfer between cache and main memory</i>

 <i>Frame: To distinguish between the data transferred and the chunk of physical </i>

 <i>Line: A portion of cache memory capable of holding one block, so-called </i>

because it is usually drawn as a horizontal object (i.e., all bytes of the line are typically drawn in one row). A line also includes control information.

<i>Tag: A portion of a cache line that is used for addressing purposes, as explained</i>

subsequently. A cache line may also include other control bits.

</div><span class="text_page_counter">Trang 4</span><div class="page_container" data-page="4">

<b>Cache Operation</b>

When the processor needs to read or write a location in the main memory, it first checks for a corresponding entry in the cache.

 <b>If the processor finds that the memory location is in the cache, a Cache Hit </b>

has occurred and data is read from the cache.

</div><span class="text_page_counter">Trang 5</span><div class="page_container" data-page="5">

 <b>If the processor does not find the memory location in the cache, a Cache Miss has occurred. For a cache miss, a block of main memory, consisting of</b>

some fixed number of words, is read into the cache and then the word is delivered to the processor.

Because of the phenomenon of locality of reference, when a block of data is fetched into the cache to satisfy a single memory reference, it is likely that there will be future references to that same memory location or to other words in the block.

<b>If a cache miss occurs, two things must be accomplished: the block containing </b>

the word must be loaded in to the cache, and the word must be delivered to the processor.

</div><span class="text_page_counter">Trang 6</span><div class="page_container" data-page="6">

<b>Cache Performance (Optional)</b>

 The performance of the cache is measured in terms of hit ratio. When CPU refers to memory and find the data or instruction within the Cache Memory, it

<b>is known as cache hit. If the desired data or instruction is not found in the </b>

cache memory and CPU refers to the main memory to find that data or

<b>instruction, it is known as a cache miss.</b>

Hit + Miss = Total CPU ReferenceHit Ratio(h) = Hit / (Hit+Miss) Miss Ratio = 1 - Hit Ratio(h)Miss Ratio = Miss / (Hit+Miss)

 Average access time of any memory system consists of two levels: Cache and Main Memory. If Tc is time to access cache memory and Tm is the time to access main memory then we can write:

Tavg = Average time to access memoryFor simultaneous access

Tavg = h * Tc + (1-h)*Tm For hierarchial access

</div><span class="text_page_counter">Trang 7</span><div class="page_container" data-page="7">

Tavg = h * Tc + (1-h)*(Tm + Tc)

</div><span class="text_page_counter">Trang 8</span><div class="page_container" data-page="8">

<b>Cache vs RAM (Optional)</b>

Although Cache and RAM b

oth

are used to increase the

performance of the system there exists a lot of differences in which they operate to increase the efficiency of the system.

OS interacts with secondarymemory to get data to be stored

in Primary Memory or RAM

OS interacts with primarymemory to get data to be stored

in Cache.It is ensured that data in RAM

are loaded before access to theCPU. This eliminates RAM miss

2. operation-in-cache-memory/

organization/

<b> Nguyên lí của bộ nhớ đệm</b>

</div><span class="text_page_counter">Trang 9</span><div class="page_container" data-page="9">

<b>Bộ nhớ Đệm là một loại bộ nhớ rất nhanh, nhỏ dùng để lưu trữ dữ liệu để các yêu cầu </b>

trong tương lai về dữ liệu đó có thể được phục vụ nhanh hơn. Bộ nhớ đệm tương tự như bộ nhớ chính.

<b>Bộ đệm hoạt động như một bộ tăng áp để làm chậm bộ nhớ chính bằng cách giữ các </b>

bản sao mã và dữ liệu thường được bộ vi xử lý yêu cầu từ bộ nhớ hệ thống chính.

<b>Các tầng bộ nhớ</b>

<small></small> <b>Tầng 1 hay thanh ghi (CPU): Nó là một loại bộ nhớ trong </b>

đó dữ liệu được lưu trữ và chấp nhận được lưu trữ ngay lập tức trong CPU. Thanh ghi được sử dụng phổ biến nhất là Thanh ghi tích lũy, Bộ đếm chương trình, Thanh ghi địa chỉ, v.v.

<small></small> <b>Tầng 2 hay bộ nhớ đệm (L1, L2, L3): Đây là bộ nhớ </b>

nhanh nhất có thời gian truy cập nhanh hơn, nơi dữ liệu được lưu trữ tạm thời để truy cập nhanh hơn.

<small></small> <b>Tầng 3 hay bộ nhớ chính (RAM): Đây là bộ nhớ mà máy </b>

tính hiện đang hoạt động. Nó có kích thước nhỏ và khi tắt nguồn, dữ liệu sẽ khơng cịn lưu trong bộ nhớ này nữa.

<small></small> <b>Tầng 4 hay bộ nhớ phụ (ổ cứng) : Đó là bộ nhớ ngồi </b>

khơng nhanh bằng bộ nhớ chính nhưng dữ liệu vẫn tồn tại vĩnh viễn trong bộ nhớ này.

SlowWord

transfer <sup>Block </sup>transferFast

</div><span class="text_page_counter">Trang 10</span><div class="page_container" data-page="10">

<b>Cấu trúc bộ đệm/bộ nhớ </b>

<i>• Khối: Đơn vị truyền tối thiểu giữa bộ đệm và bộ nhớ chính.</i>

<i>• Khung: Để phân biệt giữa dữ liệu được truyền và đoạn bộ nhớ vật lý.</i>

<i>• Dịng: Một phần bộ nhớ đệm có khả năng chứa một khối, gọi như vậy vì nó thường </i>

được vẽ dưới dạng đối tượng nằm ngang (tức là tất cả byte của dòng thường được vẽ thành một hàng). Một dịng cũng bao gồm thơng tin điều khiển.

<i>• Nhãn: Một phần của dịng bộ đệm được sử dụng cho mục đích đánh địa chỉ, như </i>

được giải thích sau. Một dịng bộ đệm cũng có thể bao gồm các bit điều khiển khác.

</div><span class="text_page_counter">Trang 11</span><div class="page_container" data-page="11">

được đọc vào bộ đệm và sau đó từ đó được gửi đến bộ xử lý.

Do hiện tượng tham chiếu cục bộ, khi một khối dữ liệu được tìm nạp vào bộ đệm để đáp ứng một tham chiếu bộ nhớ duy nhất, có khả năng sẽ có các tham chiếu trong tương lai đến cùng vị trí bộ nhớ đó hoặc tới các từ khác trong khối.

</div><span class="text_page_counter">Trang 12</span><div class="page_container" data-page="12">

Nếu xảy ra lỗi bộ đệm, hai việc phải được thực hiện: khối chứa từ phải được tải vào bộđệm và từ phải được gửi đến bộ xử lý.

</div><span class="text_page_counter">Trang 13</span><div class="page_container" data-page="13">

<b> Kết thúc bản dịch Tiếng Việt </b>

</div>

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×