Information Technology Reference
In-Depth Information
Device access. Lower levels of the software stack provide ways for the
operating system to access a wide range of I/O devices. Device drivers
hide the details of specific I/O hardware by providing hardware-specific
code for each device, and placing that code behind a simpler, more general
interfaces that the rest of the operating system can use such as a block
device interface. The device drivers execute as normal kernel-level code,
using the systems' main processors and memory, but they must interact
with the I/O devices. A system's processors and memory communicate
with its I/O devices using Memory-Mapped I/O, DMA, and Interrupts.
In the rest of this section, we first talk about the file system API and per-
formance layers. We then discuss device access.
11.3.1
API and performance
The top levels of the le system software stack|divided between application
libraries and operating system kernel code|provide the le system API and
also provide caching and write buffering to improve performance.
System calls and libraries. The file system abstraction such as the API
shown in Figure 11.6 can be provided by directly by system calls. Alternatively,
application libraries can wrap the system calls to add additional functionality
such as buffering.
For example, in Linux, applications can access files directly using system calls
(e.g., open() , read() , fwrite(), , and fclose()). .) Alternatively, applications can
use the stdio library calls (e.g., fopen() , fread() , fwrite() , and fclose() ).
The advantage of the latter is that the library includes buffers to aggregate
a program's small reads and writes into system calls that access larger blocks,
which can reduce overheads. For example, if a program uses the library function
fread() to read 1 byte of data, the fread() implementation may use the read()
system call to read a larger block of data (e.g., 4 KB) into a buffer maintained
by the library in the application's address space. Then, if the process calls
fread() again to read another byte, the library just returns the byte from the
buffer without needing to do a system call.
Block cache. Typical storage devices are much slower than a computer's
main memory. The operating system's block cache therefore caches recently
read blocks, and it buffers recently written blocks so that they can be written
back to the storage device at a later time.
In addition to improving performance by caching and write buffering, the
block cache serves as a synchronization point: because all requests for a given
block go through the block cache, the operating system includes information
 
Search WWH ::




Custom Search