1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài giảng hệ thống máy tính (computer systems) chương 2 nguyễn kim khánh

80 0 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

Nội dung

NKK-HUST Hệ thống máy tính Chương BỘ NHỚ MÁY TÍNH Nguyễn Kim Khánh Trường Đại học Bách khoa Hà Nội CS-HEDSPI2019 Computer Systems 69 NKK-HUST Nội dung học phần Chương Tổng quan hệ thống máy tính Chương Bộ nhớ máy tính Chương Hệ thống vào-ra Chương Các kiến trúc song song CS-HEDSPI2019 Computer Systems 70 NKK-HUST Nội dung chương 2.1 Tổng quan hệ thống nhớ 2.2 Bộ nhớ 2.3 Bộ nhớ đệm (cache) 2.4 Bộ nhớ 2.5 Bộ nhớ ảo CS-HEDSPI2019 Computer Systems 71 NKK-HUST 2.1 Tổng quan hệ thống nhớ Các đặc trưng nhớ n Vị trí n Bên CPU: n n Bộ nhớ trong: n n n nhớ nhớ đệm (cache) Bộ nhớ ngoài: n n tập ghi thiết bị lưu trữ Dung lượng n n CS-HEDSPI2019 Độ dài từ nhớ (tính bit) Số lượng từ nhớ Computer Systems 72 NKK-HUST Các đặc trưng nhớ (tiếp) n Đơn vị truyền n n n Phương pháp truy nhập n n n n CS-HEDSPI2019 Từ nhớ Khối nhớ Truy nhập (băng từ) Truy nhập trực tiếp (các loại đĩa) Truy nhập ngẫu nhiên (bộ nhớ bán dẫn) Truy nhập liên kết (cache) Computer Systems 73 NKK-HUST Các đặc trưng nhớ (tiếp) n Hiệu (performance) n n n n Kiểu vật lý n n n CS-HEDSPI2019 Thời gian truy nhập Chu kỳ nhớ Tốc độ truyền Bộ nhớ bán dẫn Bộ nhớ từ Bộ nhớ quang Computer Systems 74 NKK-HUST Các đặc trưng nhớ (tiếp) n Các đặc tính vật lý n n n CS-HEDSPI2019 Khả biến / Không khả biến (volatile / nonvolatile) Xố / khơng xố Tổ chức Computer Systems 75 NKK-HUST Phân cấp nhớ Bộ vi xử lý CPU Tập ghi Cache Bộ nhớ Thiết bị lưu trữ (HDD, SSD) Bộ nhớ mạng Từ trái sang phải: n dung lượng tăng dần n tốc độ giảm dần n giá thành dung lượng giảm dần CS-HEDSPI2019 Computer Systems 76 NKK-HUST Công nghệ nhớ Công nghệ nhớ Thời gian truy nhập Giá thành/GiB (2012) SRAM 0,5 – 2,5 ns $500 – $1000 DRAM 50 – 70 ns $10 – $20 Flash memory 5.000 – 50.000 ns HDD n – 20 ms $0,75 – $1 $0,05 – $0,1 Bộ nhớ lý tưởng n n CS-HEDSPI2019 Thời gian truy nhập SRAM Dung lượng giá thành ổ đĩa cứng Computer Systems 77 NKK-HUST Nguyên lý cục hoá tham chiếu nhớ Trong khoảng thời gian đủ nhỏ CPU thường tham chiếu thông tin khối nhớ cục Ví dụ: n n n n n CS-HEDSPI2019 Cấu trúc chương trình Vịng lặp có thân nhỏ Cấu trúc liệu mảng Computer Systems 78 NKK-HUST RAID 0, 1, 198 CHAPTER / EXTERNAL MEMORY strip strip strip strip strip strip strip strip strip strip strip 10 strip 11 strip 12 strip 13 strip 14 strip 15 (a) RAID (Nonredundant) strip strip strip strip strip strip strip strip strip strip strip strip strip strip strip strip strip strip strip 10 strip 11 strip strip strip 10 strip 11 strip 12 strip 13 strip 14 strip 15 strip 12 strip 13 strip 14 strip 15 b2 b3 f0(b) f1(b) f2(b) (b) RAID (Mirrored) b0 b1 (c) RAID (Redundancy through Hamming code) Figure 6.8 RAID Levels CS-HEDSPI2019 Computer Systems 134 NKK-HUST RAID & 6.2 / RAID b0 b1 b2 b3 P(b) 199 (d) RAID (Bit-interleaved parity) block block block block P(0-3) block block block block P(4-7) block block block 10 block 11 P(8-11) block 12 block 13 block 14 block 15 P(12-15) block block P(0-3) block P(4-7) Computer Systems P(8-11) block 10 block (e) RAID (Block-level parity) CS-HEDSPI2019 block block block block block block block 11 135 NKK-HUST block block block block P(4-7) block block block 10 block 11 P(8-11) block 12 block 13 block 14 block 15 P(12-15) RAID & (e) RAID (Block-level parity) block block block block P(0-3) block block block P(4-7) block block block P(8-11) block 10 block 11 block 12 P(12-15) block 13 block 14 block 15 P(16-19) block 16 block 17 block 18 block 19 (f) RAID (Block-level distributed parity) block block block block P(0-3) Q(0-3) block block block P(4-7) Q(4-7) block block block P(8-11) Q(8-11) block 10 block 11 block 12 P(12-15) Q(12-15) block 13 block 14 block 15 (g) RAID (Dual redundancy) Figure 6.8 RAID Levels (continued) second strips CS-HEDSPI2019 on each disk; and so on TheComputer advantage of this layout is that if a single Systems I/O request consists of multiple logically contiguous strips, then up to n strips for 136 NKK-HUST Ánh xạ liệu RAID 200 CHAPTER / EXTERNAL MEMORY Logical disk Physical disk Physical disk Physical disk Physical disk strip strip strip strip strip strip strip strip strip strip strip strip strip strip 10 strip 11 strip strip 12 strip 13 strip 14 strip 15 strip strip strip strip Array management software strip strip strip 10 strip 11 strip 12 strip 13 strip 14 strip 15 Figure 6.9 Data Mapping for a RAID Level Array RAID CS-HEDSPI2019 FOR HIGH DATA TRANSFER CAPACITY The performance of any of the RAID levels depends critically on the request patterns of the host system and on the layout of the data TheseComputer issues canSystems be most clearly addressed in RAID 0, where the impact of redundancy does not interfere with the analysis First, let us consider 137 NKK-HUST 2.5 Bộ nhớ ảo (Virtual Memory) n n Khái niệm nhớ ảo: gồm nhớ nhớ ngồi mà CPU coi nhớ (bộ nhớ chính) Các kỹ thuật thực nhớ ảo: n n CS-HEDSPI2019 Kỹ thuật phân trang: Chia không gian địa nhớ thành trang nhớ có kích thước nằm liền kề Thơng dụng: kích thước trang = 4KiB Kỹ thuật phân đoạn: Chia không gian nhớ thành đoạn nhớ có kích thước thay đổi, đoạn nhớ gối lên Computer Systems 138 NKK-HUST Phân trang n n n n n n Phân chia nhớ thành phần có kích thước gọi khung trang Chia chương trình (tiến trình) thành trang Cấp phát số hiệu khung trang yêu cầu cho tiến trình OS trì danh sách khung trang nhớ trống Tiến trình khơng u cầu khung trang liên tiếp Sử dụng bảng trang để quản lý CS-HEDSPI2019 Computer Systems 139 NKK-HUST chunks of some size Then the chunks of a program, known as pages, could be assigned to available chunks of memory, known as frames, or page frames At most, then, the wasted space in memory for that process is a fraction of the last page Figure 8.15 shows an example of the use of pages and frames At a given point in time, some of the frames in memory are in use and some are free The list of free frames is maintained by the OS Process A, stored on disk, consists of four pages Cấp phát khung trang Main memory Main memory Process A Page Page Page Page 13 Process A 13 Page of A 14 Page Page Page Page 14 Page of A 15 Page of A 16 In use Free frame list 20 17 In use Process A page table 18 Page of A 19 In use 15 Free frame list 13 14 15 18 20 16 In use 17 In use 18 18 19 In use 13 14 15 20 (a) Before 20 (b) After Figure 8.15 Allocation of Free Frames CS-HEDSPI2019 Computer Systems 140 NKK-HUST This approach solves the problems raised earlier Main memory is divided into many small equal-size frames Each process is divided into frame-size pages: smaller processes require fewer pages, larger processes require more When a process is brought in, its pages are loaded into available frames, and a page table is set up Địa logic địa vật lý phân trang Main memory Page Relative address number within page Logical address 30 Frame Relative address number within frame Physical address 13 30 Page of A 13 Page of A 14 Page of A 15 16 18 17 13 14 Page of A 15 18 Process A page table CS-HEDSPI2019 Figure 8.16 Logical and Physical Addresses Computer Systems 141 NKK-HUST Nguyên tắc làm việc nhớ ảo phân trang n Phân trang theo yêu cầu n n n Không yêu cầu tất trang tiến trình nằm nhớ Chỉ nạp vào nhớ trang yêu cầu Lỗi trang n n n n CS-HEDSPI2019 Trang yêu cầu khơng có nhớ HĐH cần hốn đổi trang u cầu vào Có thể cần hốn đổi trang để lấy chỗ Cần chọn trang để đưa Computer Systems 142 NKK-HUST Thất bại n n n n n Quá nhiều tiến trình nhớ nhỏ OS tiêu tốn toàn thời gian cho việc hốn đổi Có khơng có cơng việc thực Đĩa luôn sáng Giải pháp: n n n CS-HEDSPI2019 Thuật toán thay trang Giảm bớt số tiến trình chạy Thêm nhớ Computer Systems 143 NKK-HUST Lợi ích n n n n n Khơng cần tồn tiến trình nằm nhớ để chạy Có thể hốn đổi trang u cầu Như chạy tiến trình lớn tổng nhớ sẵn dùng Bộ nhớ gọi nhớ thực Người dùng cảm giác nhớ lớn nhớ thực CS-HEDSPI2019 Computer Systems 144 NKK-HUST Cấu trúc bảng trang 8.3 / MEMORY MANAGEMENT 291 Virtual address n bits Page # Offset n bits Hash function m bits Page # Control bits Process ID Chain i j 2m ! Inverted page table (one entry for each physical memory frame) Figure 8.17 CS-HEDSPI2019 Frame # Offset m bits Real address Inverted Page Table Structure inverted page table for each real memory page frame rather than one per virtual Computer Systems page Thus a fixed proportion of real memory is required for the tables regardless of 145 NKK-HUST Bộ nhớ máy tính PC n Bộ nhớ cache: tích hợp chip vi xử lý: n n n CS-HEDSPI2019 L1: cache lệnh cache liệu L2, L3 Bộ nhớ chính: Tồn dạng mơ-đun nhớ RAM Computer Systems 146 NKK-HUST Bộ nhớ PC (tiếp) n ROM BIOS chứa chương trình sau: n n n n n CMOS RAM: n n n n n Chương trình POST (Power On Self Test) Chương trình CMOS Setup Chương trình Bootstrap loader Các trình điều khiển vào-ra (BIOS) Chứa thơng tin cấu hình hệ thống Đồng hồ hệ thống Có pin ni riêng Video RAM: quản lý thơng tin hình Các loại nhớ CS-HEDSPI2019 Computer Systems 147 NKK-HUST Hết chương CS-HEDSPI2019 Computer Systems 148

Ngày đăng: 10/10/2023, 18:33