Linux I/O Flashcards
What is the main API for interacting with devices in linux?
A virtual filesystem under /dev provides access to all devices, allowing for operations like read() or write().
What is the result of creating a socket?
A file descriptor
What type of connections does a socket support?
Reliable connection-oriented byte stream | Reliable connection-oriented packet stream | Unreliable packet transmission
What system call is used for a computer to receive data from a socket?
The process must make a listen system call on a local socket, creating a buffer and blocking until data arrive.
What system call is used for sending data through a socket?
A connect system call is used, using the file descriptor of a local socket and the address of a remote socket, if the remote socket accepts a connection is established.
List the main POSIX calls for managing the terminal
cfsetospeed, cfsetispeed, cfgetospeed, cfgetispeed, tcsetattr, tcgetattr
Of which parts does a device driver consist in linux?
Two parts, top half runs in the context of the caller and interfaces with the rest of Linux; bottom half runs in kernel context and interacts with the device (hardware).
What are the components of the I/O system?
The handling of block special files and the handling of charater special devices
What is an optimization for I/O operations on block devices?
Linux has a cache between the dis drivers and the file system.
What is the purpose of the I/O scheduler and what is the Linux scheduler based on?
Its purpose is to reorder or bundle read/write requests to block devices to reduce the latency of disk-head movements. The basic Linux scheduler is based on the Linux elevator scheduler.
Explain how the linux elevator scheduler works
It keeps IOPs sorted in a doubly linked list, ordered by the address of the sector of the disk request, preventing costly disk-head movements. This leads to starvation, though, which led to the inclusion of two additional lists, maintining read / write operations by their deadlines.
Explain what are raw block files.
These are files that allow programs to access the disk using absolute block numbers, without any regards to the file system.
In which instances do character devices support random access?
Line disciplines, which serves as a modifiable buffer of a stream of characters.
How are additional device drivers loaded into a linux system
Through loadable modules. Modules have to be located during loading. The system checks if the resources required by the driver are available. The corresponding interrupt vectors must be set up. Appropriate driver switch table has to be updated and the driver is allowed to run any device specific initialization it may need.