hệ điều hànhio system chương 9 sinhvienzone com

40 63 0
hệ điều hànhio system chương 9 sinhvienzone com

Đ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

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 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn Layout Registers Interface Status Command Data CPU Memory Other Hardward-specific Chips SinhVienZone.com Internals https://fb.com/sinhvienzonevn 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) SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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) SinhVienZone.com https://fb.com/sinhvienzonevn 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) SinhVienZone.com https://fb.com/sinhvienzonevn Daisy chain bus arbitration SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn Đ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 SinhVienZone.com https://fb.com/sinhvienzonevn 10 Cấu trúc phần mềm I/O OS SinhVienZone.com https://fb.com/sinhvienzonevn 26 Đặc tính thiết bò I/O read&write SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 29 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 31 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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…) SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 37 SinhVienZone.com https://fb.com/sinhvienzonevn 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 SinhVienZone.com https://fb.com/sinhvienzonevn 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)  SinhVienZone.com https://fb.com/sinhvienzonevn 40 ... 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 SinhVienZone. com https://fb .com/ sinhvienzonevn 29 SinhVienZone. com https://fb .com/ sinhvienzonevn 30 I/O subsystem... register) SinhVienZone. com 13.2.1 https://fb .com/ sinhvienzonevn 15 Interrupt Polling Interrupt SinhVienZone. com https://fb .com/ sinhvienzonevn 16 Bảng vector ngắt Pentium processor SinhVienZone. com. .. động lên ghi controller SinhVienZone. com https://fb .com/ sinhvienzonevn 11 Một số I/O port address hệ thống PC controller controller controller SinhVienZone. com https://fb .com/ sinhvienzonevn 12 Các

Ngày đăng: 28/01/2020, 22:10

Tài liệu cùng người dùng

Tài liệu liên quan