As briefly discussed in our previous article, device driver is a software that is used to control a hardware device and make it work. It acts as an interface between the user-application and the hardware. Any user-application reaches out to the device driver for any interaction with the hardware device and the device driver checks for various conditions (like the permissions the user-application has or not etc.). After all the relevant conditions are met, the corresponding device driver responds and completes the task requested by the user-application (such as read/write to the device etc.). Finally, when the driver has completed its interaction with the hardware device, it responds back to the user-application with the information requested.
So, device driver is like a black box that means, if any user-application wants to interact with the hardware, it must go through the corresponding device driver only and not directly as it might cause any damage to the hardware.
In Operating System, the device drivers play a vital role. On the topmost level, the user application runs. Below that, the System Call Interface (SCI) is there which communicates with the device drivers that ultimately interacts with the hardware. Following picture depicts the above statements.
The SCI interacts with the Kernel space (kernel subsystems, features implemented and software support in the below diagram). As we have already discussed the kernel subsystems, we would not be going into details of them. The architecture-dependent code forms the CPU, and similarly, the various examples of device drivers can be seen at the bottom-most layer of the picture.
The device drivers can be mainly classified into three groups as below :-
- Character driver – This category deals with the character devices i.e., which transfer data character-by-character. Examples include consoles, serial port, sensors etc.
- Block driver – For the devices that transfer data by a block size (thus called block devices), the corresponding driver is called block device driver. For example, CD-ROM, USB devices etc.
- Network driver – The devices that allows us to connect to a network and use the network interface services (called network devices) have a network driver in place for them. Example – Ethernet card, NIC (Network Interface Card) etc.
Every time a new hardware device is introduced in the market, the corresponding device driver is written to interact with it.