1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

C5P1 cache memory principles

13 1 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Cache Memory Principles
Tác giả Ngô Đại Vệ
Thể loại Lecture Notes
Định dạng
Số trang 13
Dung lượng 1,54 MB

Nội dung

Bộ nhớ đệm (Cache)- kiến trúc máy tính. nó bấm chữ thì không được, mà cứ chê bạn mô tả quá ngắn phải bấm chỗ khác rồi dán vô, muốn chửi thề, bấm được 1 chữ thì đơ ra đó mà đòi dài. Cứ cà dựt cà dựt không cho bấm

Trang 1

5.1 Cache Memory Principles

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

that future requests for that data can be served faster The cache

contains a copy of portions of the main memory

Cache operates as a turbocharger to slower main memory by holding copies of code

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 are immediately 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

Levels of Memory

Level 1 or Register (CPU): It is a type of memory in

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

Level 2 or Cache memory (L1, L2, L3): It is the fastest

memory that has faster access time where data is

temporarily stored for faster access

Level 3 or Main Memory (RAM): It is the memory on

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

Level 4 or Secondary Memory (Hard disk) : It is

external memory that is not as fast as the main memory

Slow Word

transfer FastBlock transfer

Trang 2

Cache/Memory Structure

Block: The minimum unit of transfer between cache and main memory

Frame: To distinguish between the data transferred and the chunk of physical

memory

Line: A portion of cache memory capable of holding one block, so-called

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

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

subsequently A cache line may also include other control bits

Trang 4

Cache Operation

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

If the processor finds that the memory location is in the cache, a Cache Hit

has occurred and data is read from the cache

Trang 5

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

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

If a cache miss occurs, two things must be accomplished: the block containing

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

Trang 6

Cache Performance (Optional)

 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

is known as cache hit If the desired data or instruction is not found in the

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

instruction, it is known as a cache miss.

Hit + Miss = Total CPU Reference

Hit 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 memory

For simultaneous access

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

For hierarchial access

Trang 7

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

Trang 8

Cache vs RAM (Optional)

Although Cache and RAM both 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

RAM is larger in size compared

to cache Memory ranges from

1MB to 16GB

The cache is smaller in size

Memory ranges from 2KB to a

few MB generally

It stores data that is currently

OS interacts with secondary

memory to get data to be stored

in Primary Memory or RAM

OS interacts with primary memory to get data to be stored

in Cache

It is ensured that data in RAM

are loaded before access to the

CPU This eliminates RAM miss

never

CPU searches for data in Cache,

if not found cache miss occur

End of English Version -References

1 William Stallings - Computer organization and architecture _ designing for performancePearson Education Limited

-11th edition (2019)

2 https://en.wikipedia.org/wiki/Cache_(computing)

3 https://techmonitor.ai/what-is/what-is-cache-memory

4

https://www.geeksforgeeks.org/cache-organization-set-1-introduction/?ref=lbp

5 https://www.geeksforgeeks.org/cache-memory/?ref=lbp

6 https://www.geeksforgeeks.org/locality-of-reference-and-cache-operation-in-cache-memory/

7

https://www.geeksforgeeks.org/cache-memory-in-computer-organization/

5.1 Nguyên lí của bộ nhớ đệm

Trang 9

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

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ộ đệ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ả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

Các tầng bộ nhớ

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

đó 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

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

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

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

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

Tầng 4 hay bộ nhớ phụ (ổ cứng) : Đó là bộ nhớ ngoài

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

Slow

Word transfer Block transfer

Fast

Trang 10

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

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

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

• 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

đượ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

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

đượ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

Trang 11

Hoạt động của bộ đệm

Khi bộ xử lý cần đọc hoặc ghi một vị trí trong bộ nhớ chính, trước tiên nó sẽ kiểm tra mục nhập tương ứng trong bộ đệm

• Nếu bộ xử lý nhận thấy vị trí bộ nhớ nằm trong bộ nhớ đệm thì một lần truy cập bộ đệm đã xảy ra và dữ liệu được đọc từ bộ nhớ đệm.

• Nếu bộ xử lý không tìm thấy vị trí bộ nhớ trong bộ nhớ đệm thì đã xảy ra lỗi

bộ đệm Đối với lỗi bộ đệm, một khối bộ nhớ chính, bao gồm một số từ cố định,

đượ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

Trang 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ý

Trang 13

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

Ngày đăng: 17/05/2024, 22:49

TỪ KHÓA LIÊN QUAN

w