[Operating System] {ud923} P3L5: I/O Management

 Visual Metaphor

 I/O Devices

 

 

I/O Device Features 

status registers => for CPU to find out what's happening on the device

command registers => for CPU to control what exactly the device will be doing

data registers => for CPU to control the I/O of the device

Figure 36.2 Reference

Figure 36.2 is referenced from the "I/O Devices" section in Three Easy Pieces.

 CPU Device Interconnect

Device Drivers

Here is a link to HP Device Drivers (like the drivers mentioned @1:13).

 Types of Devices

 

lp => line printer

 

Click the following links to find out more information about /dev/null (also known as the Null device) and /dev/random.

 if you want to discard the output of  a process  you can send it to /dev/null

a more robust conterpart of dev/random is dev/urandom => create files with random bites

Ubnutu VM Setup Instructions

 CPU Device Interactions

interrupt or polling should be depent on the device type and the objectives.

 interrupt: signal sent from device to CPU

polling: for CPU to access device

Method1:Device Access PIO

 

 Method2:Device Access DMA

 

 

the answer to each question will depend heavily on the size of data packets.

Typical Device Access

 

 OS Bypass

 

 Sync vs. Async Access

 

Block Device Stack 

 

generic block layer => knows how exactly to interact with a particular driver

=> how to pass thoes operations to the particular driver and how to interpret the error messages or notifications or responses that are generated by that driver.

driver-device => protocal 

 

Quiz Help

http://man7.org/linux/man-pages/man2/ioctl_list.2.html

 

 Virtual File System

 

 

Virtual File System will specify a more detailed set of local file systems, performing the necessary translations.

Virtual File System Abstractions 

 

OS represent files via file descriptors. A file descriptor is created when the file is first openen.

For each file, VFS maintains a persistent data structure called inode. => inode is a standard data structure in Unix-based system. => The file doesn't need to be stored contiguously on disk, and therefore, it's important to maintain this "index" (inode).

To help with certain operations on directories, Linux maintains a data structure called dentry, stands for directory entry. => FS will maintain a cache of all the directory entries that have been visited. and we call that the dentry cache.

superblock => like a map that file system maintains so it can figure out how has it organized on disk

 VFS on Disk

 

 ext2 Second Extended Filesystem

inodes 

 

 inodes with Indirect Pointers

 


 https://zhuanlan.zhihu.com/p/24572756

 


Maximum File Size:

  • number_of_addressable_blocks * block_size
  • number_of_addressable_blocks = 12 + blocks_addressable_by_single_indirect + blocks_addressable_by_double_indirect + blocks_addressable_by_triple_indirect

You do not have to include units in your answers.

ERRATA

Properly rounding up the first answer results in 17GB or 16GiB (where GB is 10^(33) and GiB is 2^(310).

 Disk Access Optimizations

 

as opposed to writing out the data in the proper disk location, we write updates in a log. so the log will contain some description of the write that supposed to take place.

"block", "offset", and "value" essentially describes an individual write.

Note that journal has to be periodically updated into proper dislocation, otherwise it will just grow indefinitely and it will be really hard to find anything

Four techniques contribute to reducing the file system overheads and latencies.

This is done by increasing the likelihood of accessing data from memory, by not having to wait for the slow disk head movements.

原文地址:https://www.cnblogs.com/ecoflex/p/10928715.html