Documente Academic
Documente Profesional
Documente Cultură
One of the purposes of an operating system is to hide the characteristic of the system's hardware devices from its users. every physical device has its own hardware controller. Each hardware controller has its own control and status registers (CSRs) and these differ between devices. The software that handles or manages a hardware controller is known as a device driver. A device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device.
Ramanuj Chouksey
Ramanuj Chouksey
Overall Architecture
System Call Interface VFS File Systems Buffer Cache Block Character Device Driver Device Driver Network Protocol Socket
Hardware
Device Types
Linux supports three types of hardware devices: Character block Network Character devices are read and written directly without buffering. character devices provide only a serial stream of input or output; Examples include printers, scanners, sound boards, keyboard.
Device Types
Block devices can only be written to and read from in multiples of the block size, typically 512 or 1024 bytes. Block devices are accessed via the buffer cache and may be randomly accessed. Block devices can be accessed via their device special file but more commonly they are accessed via the file system. Only a block device can support a mounted file system. For example, disks are commonly implemented as block devices. Network devices are accessed via the BSD socket interface a
Ramanuj Chouksey
device file
A device file or special file is an interface for a device driver that appears in a file system as if it were an ordinary file. They allow software to interact with a device driver using standard input/output system calls, which simplifies many tasks and unifies user-space I/O mechanisms. There are two general kinds of device files in Unix-like operating systems, known as
character special files block special files
The difference between them lies in how data written to them and read from them is processed by the operating system and hardware
device file
device file is a special type of file. A device file points to an inode that contains some associated information: a major device number and a minor device number. When you carry out a file operation on a device file, the system uses the major number to determine which device driver to use to read data from or write data to the device. (The minor number is used internally by the device driver.) Device file allows transparent communication between user space applications and computer hardware.
Minor number
This uniquely identifies a particular instance of a device. For example, a system may have multiple IDE hard disks each would have a major number of 3, but a different minor number.
Ramanuj Chouksey
Ramanuj Chouksey
Character Devices
Character devices, the simplest of Linux's devices, are accessed as files, applications use standard system calls to open them, read from them, write to them and close them exactly as if the device were a file. As a character device is initialized its device driver registers itself with the Linux kernel by adding an entry into the chrdevs vector of device_struct data structures. The device's major device identifier is used as an index into this vector
Ramanuj Chouksey
Character Devices
Each entry in the chrdevs vector, a device_struct data structure contains two elements: pointer to the name of the registered device driver pointer to a block of file operations. The block of file operations is itself the addresses of routines within the character device driver, each of which handles specific file operations such as open, read, write and close.
Ramanuj Chouksey