Home » Device Driver in Operating System

Device Driver in Operating System

by Online Tutorials Library

Device Driver in Operating System

Operating System takes help from device drivers to handle all I/O devices. A device driver is a computer program that operates or controls a particular device attached to a computer or automaton. A driver provides a software interface to hardware devices, enabling operating systems and other computer programs to access hardware functions without knowing precise details about the hardware being used.

Device Drivers are important for a computer system to work properly. Without a device driver, the particular hardware fails to work accordingly, which means it fails in doing a particular action for which it has been created.

Drivers are hardware-dependent and operating-system-specific. They usually provide the interrupt handling required for any necessary asynchronous time-dependent hardware interface.

A driver communicates with the device through the computer bus or communications subsystem to which the hardware connects. Once the device sends data back to the driver, the driver may invoke routines in the original calling program. When a calling program invokes a driver’s routine, the driver issues the commands to the device.

Device Driver in Operating System

Device drivers encapsulate device-dependent code and implement a standard interface to contain device-specific register reads or writes. A device driver is generally written by the device’s manufacturer and delivered along with the device on a CD-ROM. A device driver performs the following jobs, such as:

  • To accept request from the device-independent software above to it.
  • Making sure that the request is executed successfully.
  • Interact with the device controller to take and give I/O and perform required error handling.

How Device Driver Handles a Request?

How a device driver handles a request in the operating system is as follows:

Suppose a request comes to read a block N. If the driver is idle when a request arrives, it starts carrying out the request immediately. Otherwise, if the driver is already busy with some other request, it places the new request in the queue of pending requests.

Purpose of a Device Driver

The main purpose of device drivers is to provide abstraction by acting as a translator between a hardware device and the applications or operating systems that use it. Programmers can write higher-level application code independently of whatever specific hardware the end-user is using.

For example, a high-level application interacting with a serial port may have “send data” and “receive data” functions. A device driver implementing these functions would communicate to the particular serial port controller installed at a lower level on a user’s computer.

The commands needed to control a 16550 UART are different from those needed to control an FTDI serial port converter. Still, each hardware-specific device driver abstracts these details into the same or similar software interface.

How does Device Driver work?

When you get a peripheral device such as a 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 it.

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 connects the device with the computer. Device Drivers depend upon the Operating System’s instruction to access the device and performing any particular action. After the action, they also show their reactions by delivering output or message from the hardware device to the Operating system.

Device Driver in Operating System

Device drivers work within the kernel layer of the operating system. The kernel is the part of the operating system that directly interacts with the system’s physical structure. Instead of accessing a device directly, an operating system loads the device drivers and calls the specific functions in the driver software to execute specific tasks on the device. Each driver contains the device-specific codes required to carry out the actions on the device.

Card reader, controller, modem, network card, sound card, printer, video card, USB devices, RAM, Speakers etc., need Device Drivers to operate. For example, a printer driver tells the printer which format to print after getting instructions from OS. Similarly, A sound card driver is there because the 1’s and 0’s data of an MP3 file is converted to audio signals, and you enjoy the music.

Types of Device Driver

For almost every device associated with the computer system, a Device Driver exists for the particular hardware. But it can be broadly classified into the following two types, such as:

Device Driver in Operating System

1. Kernel-mode Device Driver

This Kernel-mode device driver includes some generic hardware that loads with an operating system as part of the OS. These are BIOS, motherboard, processor, and some other hardware that are part of kernel software. These include the minimum system requirement device drivers for each operating system.

  • BIOS: BIOS (basic input/output system) is the most basic computer driver in existence. It is designed to be the first program that boots when a PC turns on. The BIOS is stored on memory built into the motherboard and is designed to boot the hardware connected to the PC, including the hard drives, video display output, keyboard and mouse.
  • Motherboard Drivers: Motherboard drivers are small programs that are read by either Windows or Linux and allow for basic computer functions while inside the operating system. These drivers normally include programs that allow broadband ports, USB ports and I/O ports for the mouse and keyboard. Depending on the making of the motherboard, the drivers may also have basic drivers for video and audio support.

2. User-mode Device Driver

Other than the devices brought by the kernel for working of the system, the user also brings some devices for use during the using of a system that devices need device drivers to functions those drivers fall under User mode device driver. For example, the user needs any plug and play action that comes under this.

Applications of Device Drivers

Because of the diversity of modern hardware and operating systems, drivers operate in many different environments. Device drivers may interface with Printers, Video adapters, Network cards, Sound cards, Local buses of various sorts, Image scanners, Digital cameras, Digital terrestrial television tuners, IrDA adapters, and Implementing support for different file systems. It also interfaces with:

  • Low-bandwidthI/O buses of various sorts for pointing devices such as mice, keyboards, etc.
  • Computer storagedevices such as hard disk, CD-ROM, and floppy disk buses (ATA, SATA, SCSI, SAS)
  • The radio-frequency communication transceiver adapters are used for short-distance and low-rate wireless communication in home automation, such as Bluetooth Low Energy (BLE), Thread, ZigBee, and Z-Wave).

Choosing and installing the correct device drivers for given hardware is often a key component of computer system configuration. Common levels of abstraction for device drivers include:

1. For hardware:

  • Interfacing directly
  • Writing to or reading from a device control register
  • Using some higher-level interface (e.g. Video BIOS)
  • Using another lower-level device driver (e.g. file system drivers using disk drivers)
  • Simulating work with hardware while doing something entirely different.

2. For software:

  • Allowing the operating system direct access to hardware resources
  • Implementing only primitives
  • Implementing an interface for non-driver software (e.g. TWAIN)
  • Implementing a language, sometimes quite high-level (e.g. PostScript)

What is Virtual Device Drivers

Virtual device drivers represent a particular variant of device drivers. They are used to emulate a hardware device, particularly in virtualization environments, for example, when a DOS program is run on a Microsoft Windows computer or when a guest operating system is run on a Xen host. Instead of enabling the guest operating system to dialogue with hardware, virtual device drivers take the opposite role and emulates a piece of hardware. The guest operating system and its drivers running inside a virtual machine can have the illusion of accessing real hardware.

Attempts by the guest operating system to access the hardware are routed to the virtual device driver in the host operating system as function calls. The virtual device driver can also send simulated processor-level events like interrupts into the virtual machine.

Virtual devices may also operate in a non-virtualized environment. For example, a virtual network adapter is used with a virtual private network, while a virtual disk device is used with iSCSI. There are several variants of virtual device drivers, such as VxDs, VLMs, and VDDs. A good example of a virtual device driver is the Daemon Tools.


You may also like