Home


Content

Device Management

I/O Operations


📠 Device Management

The Device Management controls every piece of hardware and virtual device on a computer. The OS use the concept of drivers to establish a connection between these devices with the system.

Functions of Device Management:

There are three types of device management:

  1. Boot device: It stores information in a fixed-size block, each one with its own address. Example, disks.
  2. Character device: It delivers or accepts a stream of characters. The individual characters are not addressable. For example, printers and keyboards.
  3. Network device: Responsible for transmitting data packets.

Types of devices

Dedicated Device

Certain devices are assigned to only one task at a time in device management until that task releases them. Plotters, printers, tape drives, and other similar devices require this kind of allocation method because sharing them with numerous users at the same time will be inconvenient. The drawback of these devices is the inefficiency that results from assigning the device to a single user throughout the entirety of the task execution process, even in cases when the device is not utilized exclusively.

Shared Device

There are numerous processes that these devices could be assigned to. Disk-DASD could be shared concurrently by many processes by interleaving their requests. All issues must be resolved by pre-established policies, and the Device Manager closely monitors the interleaving.

Virtual Device

Virtual devices are dedicated devices that have been converted into shared devices, making them a hybrid of the two types of devices. For instance, a spooling programme that routes all print requests to a disc can turn a printer into a sharing device. A print job is routed to the disc and not delivered straight to the printer until it is ready with all the necessary formatting and sequencing, at which time it is sent to the printers. The method can increase usability and performance by turning a single printer into a number of virtual printers.

Techniques for accessing a device

  1. Polling: The CPU keeps an eye on the status of the device to data with. When an input/output operation is needed, the computer keeps track of the I/O device’s status until it’s ready.
  2. Interrupt-driven I/O: The device controller notifies the associated driver of the device’s availability. One interrupt for each keyboard input results in slower data copying and movement for character devices, but the advantages include more effective use of CPU cycles.
  3. Direct Memory Access (DMA): DMA is the process of transferring data using a second controller without CPU usage. However, it has a drawback of preventing data access from a process that is in transit.
  4. Double Buffering: This mode of access has two buffers. One fills up while the other is utilized, and vice versa. In order to hide the line-by-line scanning from the viewer, this technique is frequently employed in animation and graphics.

Device Driver

Device Drivers enable different hardware devices to communicate with the computer’s OS. A device driver communicates with the computer hardware by computer subsystem or computer bus connected to the hardware.

driver-21.png

Types of Device Driver:

  1. Kernel-mode Device Driver: The Kernel-mode device driver includes some generic hardware that loads with the operating system as part of the OS. These are BIOS, motherboard, processor, and some other hardware that are part of kernel software. It includes the minimum system requirement device drivers for each operating system.
  2. User-mode Device Driver: This driver is used for devices brought by the user such as keyboard, mouses, and monitors.
  3. Virtual Device Driver: Used by software components that simulate hardware devices such as VMs, and virtual audio cables.

🔃 I/O Operations

The requests are served by OS using three simple segments

  1. I/O Traffic Controller: Keeps track of the status of all devices, control units, and communication channels.
  2. I/O scheduler: Executes the policies used by OS to allocate and access the device, control units, and communication channels.
  3. I/O device handler: Serves the device interrupts and heads the transfer of data.

SharedMemorySoham.png

Scheduling is used for efficient usage of computer resources avoiding deadlock and serving all processes waiting in the queue.

I/O Traffic Controller has 3 main tasks:

Buffers

I/O buffering is a technique that involves the temporary storage of data in a buffer, which is a reserved area of memory, to reduce the number of I/O operations and manage the flow of data between fast and slow devices or processes.

Types of I/O buffering techniques

  1. Single Buffer: Uses one buffer to store data temporarily. A buffer is provided by the operating system to the system portion of the main memory.
  2. Double Buffer: Uses two buffers to allow continuous data transfer between two process or two devices.
  3. Circular Buffer: When more than two buffers are used, the collection of buffers itself is referred to as a circular buffer.

Caching

Caching in I/O operations is a fundamental technique to improve performance by reducing the need for repetitive slow I/O operations.

Scheduling

I/O Scheduler functions similarly to process schedulers, it allocates the devices, control units, and communication channels. However, under a heavy load of I/O requests, Scheduler must decide what request should be served first and for that we multiple queues to be managed by OS.

The major difference between a process scheduler and an I/O scheduler is that I/O requests are not preempted: Once the channel program has started, it’s allowed to continue to completion. Although it is feasible because programs are relatively short (50 to 100 ms).

Some modern OS allows I/O Scheduler to serve higher priority requests. In simpler words, If an I/O request has higher priority then they are served before other I/O requests with lower priority. The I/O scheduler works in coordination with the I/O traffic controller to keep track of which path is being served for the current I/O request. I/O Device Handler manages the I/O interrupts (if any) and scheduling algorithms.