1. Trang chủ
  2. » Giáo án - Bài giảng

he dieu hanh io system cuuduongthancong com

40 2 0

Đ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

I/O System     I/O subsystem trình điều khiển Phần cứng I/O Giao diện I/O cho ứng dụng Hiệu suất I/O CuuDuongThanCong.com https://fb.com/tailieudientucntt Phân loại chung thiết bị I/O    Thiết bị lưu trữ (storage devices) đóa, băng từ Thiết bị truyền liệu (transmission devices) network card, modem; Thiết bị giao diện người-máy (human-interface devices) hình, bàn phím, chuột CuuDuongThanCong.com https://fb.com/tailieudientucntt Layout Registers Interface Status Command Data CPU Memory Other Hardward-specific Chips CuuDuongThanCong.com Internals https://fb.com/tailieudientucntt Phần mềm I/O OS   Thành phần I/O subsystem OS cung cấp dịch vụ liên quan đến I/O cho ứng dụng số thành phần khác kernel Các trình điều khiển thiết bị (device driver) cung cấp đến I/O subsystem giao diện để truy cập thiết bị Ví dụ:   Hàm để đọc disk block (đóa) Hàm để ghi chuỗi ký tự (printer) CuuDuongThanCong.com https://fb.com/tailieudientucntt Vấn đề thiết kế driver  Trường hợp driver có giao diện khác OS   Để giao diện đến driver phải tốn công lập trình Trường hợp driver có (hoặc số ít) loại giao diện OS  Dễ dàng gắn driver tuân theo (conform) giao diện định CuuDuongThanCong.com https://fb.com/tailieudientucntt From Tanenbaum Giao diện driver đồng  Các driver phải theo (conform) giao diện định nghóa trước Do người thiết kế driver biết trước    phải cung cấp hàm cho phần lại OS phép gọi hàm kernel (vd kmalloc, cài đặt IRQ handler…) Có hai loại driver chủ yếu: block driver (vd đóa) character driver (vd printer) CuuDuongThanCong.com https://fb.com/tailieudientucntt Phần cứng I/O Các thành phần  Điểm kết nối vật lý – nơi kết nối thiết bị I/O hệ thống máy tính    Port (connection point)  USB port  Serial port … Bus Bộ điều khiển  Controller (device controller, SCSI controller) CuuDuongThanCong.com https://fb.com/tailieudientucntt Daisy chain bus arbitration CuuDuongThanCong.com https://fb.com/tailieudientucntt Tổ chức phần cứng I/O hệ thống PC SCSI disk controller SCSI host bus adapter IDE host bus adapter IDE disk controller CuuDuongThanCong.com https://fb.com/tailieudientucntt Điều khiển thiết bị I/O Trên device controller có  Thanh ghi lệnh để nhận yêu cầu I/O từ OS (command/ control register)  Thanh ghi tình trạng (status register) để báo tình trạng sẵn sàng / bận / lỗi thiết bị  Thanh ghi liệu (data register) – đọc liệu từ thiết bị qua data-in reg hay ghi liệu thiết bị qua data-out reg Device controller control reg CPU status reg input reg device output reg CuuDuongThanCong.com https://fb.com/tailieudientucntt 10 Cấu trúc phần mềm I/O OS CuuDuongThanCong.com https://fb.com/tailieudientucntt 26 Đặc tính thiết bị I/O read&write CuuDuongThanCong.com https://fb.com/tailieudientucntt 27 Các dịch vụ I/O cho ứng dụng  Giao diện chuẩn đồng cho thiết bị     Thiết bị khối (block device)  Disk  Tác vụ: read, write, seek Thiết bị kí tự (character device)  Keyboard, mouse, serial port, line printer,…  Tác vụ: get, put Thiết bị mạng (network device)  Block character  Socket interface Unix, Windows/NT,… Clock timer   Cung cấp thời gian tại, timer Có thể lập trình CuuDuongThanCong.com https://fb.com/tailieudientucntt 28 System call yêu cầu I/O  Blocking: process bị suspended I/O hoàn tất    Nonblocking: I/O call returns as much as available     Dễ dàng sử dụng Không hiệu số trường hợp Ví dụ: data copy (buffered I/O) Thường thực với multithreading Returns quickly with count of bytes read or written Asynchronous: process thực thi lúc hệ thống thực I/O   Khó sử dụng I/O subsystem báo hiệu cho process I/O hoàn tất CuuDuongThanCong.com https://fb.com/tailieudientucntt 29 CuuDuongThanCong.com https://fb.com/tailieudientucntt 30 I/O subsystem (1) •  I/O subsystem thực kỹ thuật giảm overhead hệ thống I/O xử lý lỗi Định thời yêu cầu I/O   Các yêu cầu I/O xếp hàng hàng đợi thiết bị Bảo đảm công bằng, hiệu suất cao CuuDuongThanCong.com https://fb.com/tailieudientucntt 31 CuuDuongThanCong.com https://fb.com/tailieudientucntt 32  Đệm liệu (buffering): lưu liệu tạm thời nhớ thực I/O  Buffer vùng nhớ để lưu liệu truyền hai thiết bị hay thiết bị ứng dụng CuuDuongThanCong.com https://fb.com/tailieudientucntt 33 I/O subsystem (tt) (tt)  Hỗ trợ thực I/O hữu hiệu trường hợp chênh lệch tốc độ hay kích thước liệu  Một trình đọc liệu từ modem lưu vào đóa Thay đọc character (dùng read system call) từ modem phải block đợi char trình cung cấp nchar buffer user space gọi read n char; buffer đầy trình đánh thức Process User space Kernel space to buffer • From Tanenbaum CuuDuongThanCong.com https://fb.com/tailieudientucntt 34 I/O subsystem (2) •  (tt) Caching   Cache vùng nhớ nhanh để giữ copy liệu lưu nhớ chậm Spooling  Spool vùng nhớ đệm để lưu output cho loại thiết bị không nhận luồng liệu đan xen (máy in…) CuuDuongThanCong.com https://fb.com/tailieudientucntt 35 I/O subsystem (3) •  (tt) Xử lý lỗi (error handling)     Phân loại lỗi  Lỗi thời (transient), vd mạng tãi  Lỗi lâu dài (permanent), vd disk controller hư OS phục hồi số lỗi thời  Vd thực thi lại (retry) lệnh send( ) gói liệu vào mạng, send( ) trước không thành công Khi I/O system call không thành công, OS thường trả thêm mã lỗi (error code) cho biết thêm nguyên nhân lỗi (vd lỗi phần cứng, timeout,…) OS trì nhật ký lỗi hệ thống (system error log) lưu tường trình lỗi CuuDuongThanCong.com https://fb.com/tailieudientucntt 36 Hiệu suất I/O (1)  Hiệu suất I/O ảnh hưởng lớn đến hiệu suất toàn hệ thống I/O gây overhead     CPU thực thi lệnh device driver kernel I/O code Chuyển ngữ cảnh I/O interrupt Gây tải lên bus nhớ copy liệu nhớ controller, kernel buffer user buffer Network traffic khiến tần suất chuyển ngữ cảnh cao CuuDuongThanCong.com https://fb.com/tailieudientucntt 37 CuuDuongThanCong.com https://fb.com/tailieudientucntt 38 Hiệu suất I/O (2)  Tăng hiệu suất I/O cách giảm I/O overhead     Giảm số lần chuyển ngữ cảnh I/O device interrupt Giảm số lần copy liệu buffer thiết bị trình Giảm số lần ngắt quãng  Truyền khối liệu lớn  Dùng controller thông minh  Dùng kỹ thuật polling thời gian busy waiting nhỏ Sử dụng DMA CuuDuongThanCong.com https://fb.com/tailieudientucntt 39 Tài liệu tham khảo Chapter: I/O devices Operating Systems: Three Easy Pieces Remzi H Arpaci-Dusseau and Andrea C Arpaci-Dusseau Arpaci-Dusseau Books, Inc January, 2014 (Version 0.8)  CuuDuongThanCong.com https://fb.com/tailieudientucntt 40 ... diện người-máy (human-interface devices) hình, bàn phím, chuột CuuDuongThanCong.com https://fb.com/tailieudientucntt Layout Registers Interface Status Command Data CPU Memory Other Hardward-specific... khảo Chapter: I/O devices Operating Systems: Three Easy Pieces Remzi H Arpaci-Dusseau and Andrea C Arpaci-Dusseau Arpaci-Dusseau Books, Inc January, 2014 (Version 0.8)  CuuDuongThanCong.com https://fb.com/tailieudientucntt... chuyện’ với kỹ thuật  Port-mapped I/O  Dùng lệnh I/O lên địa I/O port (I/O port address) để tác động lên ghi controller;  Trên Intel processor có lệnh I/O IN, OUT  Memory-mapped I/O   Mỗi ghi

Ngày đăng: 27/12/2022, 14:18