When learning the operating system, we all know the role of DMA (direct memory read), the previous I/O is called a system interrupt to tell the CPU I moved to 4k of data block for the CPU to calculate,
In this cycle, the CPU interacts with the I/O more often, and the DMA is transferred to the CPU using chunks of data (much larger than 4k).
So before the DMA transfer task is complete, the CPU is having a lot of events to be merry.
Let's look at the Java Virtual machine, the traditional Java I/O class like to read small chunks of data, this time to obtain the DMA provided by the large buffer, the Java stream data class will be
He tore up a lot of small pieces. This greatly reduces efficiency, so Java launches the NIO (Bytebuffer object).
Traditional I/O models can actually move large amounts of data, randomaccessfile using the array-based read () and write () methods, which are fairly close to system calls, but
He must keep at least one copy of the buffer.
/ o
User space is what we often say (non-privileged areas, can not directly invoke system rights such as reading hardware devices), the kernel space is the pipe (privileged area, for the operating system
Licensee
Why can't I read data directly from disk to user space?
Because a block of data on a disk is a fixed size and the user process is requesting a block of arbitrary size or even a boundary misalignment, a third party (kernel) is required to
The data is divided, combined, and forwarded.
Basic concepts
Go to NiO: buffers (buffer)
The following diagram describes the buffer family members
Properties of the buffer: capacity, upper bound, position, tag.
Capacity (capcapacity): The maximum number of data that a buffer can hold.
Upper bound (Limit): The first element in a buffer that cannot read/write. That is, the current buffer has the number of elements.
Location (Position):
Java NiO Learning Summary (i)