When we get a peripheral device such as printer, scanner, keyboard or modem, the device comes together with a driver CD which needs to be installed before the device starts working. As soon we install the driver software into the computer, it detects and identifies the peripheral device and we become able to control the device with the computer. A device driver is a piece of software that allows your computer’s operating system to communicate with a hardware device, the driver is written for. Generally a driver communicates with the device through the computer bus which is used to connect the device with the computer.
Device drivers works within the kernel layer of the operating system. Kernel is the part of the operating system that directly interacts with the physical structure of the system. Instead of accessing a device directly, an operating system loads the device drivers and calls the specific functions in the driver software in order to execute specific tasks on the device. Each driver contains the device specific codes required to carry out the actions on the device.
Let’s take an example of a printer, when it is connected to the computer and the specific device driver is installed, a device object is created on the computer which is designed to control the device. This device object represents the printer and its physical structure modes that allow your computer’s operating system to control its functions. When we choose an operation (like Control + P to print a document) on the printer then this command goes to the device driver through the kernel of the operating system. Resultantly a calling program invokes a routine in the device driver and the driver issues corresponding commands to the microcontrollers within the printer. Further these microcontrollers control the components of the printer like motors etc. to start printing the document.