linux device drivers 2nd edition phần 8

Các hệ thống Unix từ lâu đã cung cấp một "nguyên liệu" giao diện một số thiết bị khối thiết bị đặc biệt, thực hiện I / O trực tiếp từ người sử dụng một bộ đệm không gian và tránh sao chép dữ liệu thông qua các hạt nhân. Trong một số trường hợp có nhiều cải thiện hiệu suất có thể có được theo cách này, | The kiobuf Interface int lock_kiovec int nr struct kiobuf iovec int wait int unlock_kiovec int nr struct kiobuf iovec Locking a kiovec in this manner is unnecessary however for most applications of kiobufs seen in device drivers. Mapping User-Space Buffers and Raw I O Unix systems have long provided a raw interface to some devices block devices in particular which performs I O directly from a user-space buffer and avoids copying data through the kernel. In some cases much improved performance can be had in this manner especially if the data being transferred will not be used again in the near future. For example disk backups typically read a great deal of data from the disk exactly once then forget about it. Running the backup via a raw interface will avoid filling the system buffer cache with useless data. The Linux kernel has traditionally not provided a raw interface for a number of reasons. As the system gains in popularity however more applications that expect to be able to do raw I O such as large database management systems are being ported. So the development series finally added raw I O the driving force behind the kiobuf interface was the need to provide this capability. Raw I O is not always the great performance boost that some people think it should be and driver writers should not rush out to add the capability just because they can. The overhead of setting up a raw transfer can be significant and the advantages of buffering data in the kernel are lost. For example note that raw I O operations almost always must be synchronous the write system call cannot return until the operation is complete. Linux currently lacks the mechanisms that user programs need to be able to safely perform asynchronous raw I O on a user buffer. In this section we add a raw I O capability to the sbull sample block driver. When kiobufs are available sbull actually registers two devices. The block sbull device was examined in detail in Chapter 12. What we didn t see in that

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.