Linux I/O (二):A Process Of Reading Disk File

What’s IO?

IO(Input/Output) is a system of communication for information processing systems.
structure of information processing system, as follows:

information processing systems In computing, IO is the communication between an information processing system , such as a computer, and the outside world, possibly a human or another information processing systems, such as keyboards and mouse are input-only devices while devices such as printers are output-only. A writable CD-ROM is both an input and an output device.

IO is a system of communication, structure of IO system in linux, as follows:

archetectureofkernelio

由上图可看出:设备驱动作为中间联络人,负责操作系统与设备之间信息交流,不同设备对应不同的设备驱动。
IO subsystem:[向下] 通过安装设备驱动,横向扩展可访问设备种类;[向上]通过封装统一访问入口,降低上层应用访问各设备的复杂度。

Read More...

Key In Http Protocol (一):'Cache-Control'

Brief

HTTP (Hypertext Transfer Protocol) is perhaps the most popular application protocol used in the Internet (or The WEB).

HTTP is an asymmetric request-response client-server protocol as illustrated. An HTTP client sends a request message to an HTTP server. The server, in turn, returns a response message.

In other words, HTTP is a pull protocol, the client pulls information from the server (instead of server pushes information down to the client).

HTTP is a client-server application-level protocol.

HTTP

① http response message

HTTP_ResponseMessageExample

② http request message

HTTP_RequestMessageExample

Read More...

Linux I/O (一):Nio Is Real 'Zero-Copy'?

What Is ‘Zero-Copy’?

Zero copy refers to a collection of techniques which reduce the number of copies of blocks of data in order to make data transfer more efficient. This helps reduce the number of unnecessary memory accesses and CPU consumption, and therefore enhance overall system performance.

“零拷贝”并非字面上意思。下面以“一次网络数据包读取流程”为例,讲解什么是“零拷贝技术” ? 采用“传统方式”,需要两次DMA拷贝,两次CPU拷贝。借用“sendfile()”方式,仅需要一次内存拷贝,两次DMA拷贝。

two CPU copy  two DMA copy

nio-traditional

实例代码:

    read(file, tmp_buf, len);
    write(socket, tmp_buf, len);

one CPU copy  two DMA copy

nio_sendfile

Read More...