The path between the operating system and virtually all hardware not on the computer's motherboard goes through special programs called drivers. Much of a driver's function is to be the translator between the electrical signals of the hardware subsystems and the high-level programming languages of the operating system and application programs. Drivers take data that the operating system has defined as a file and translate them into streams of bits placed in specific locations on storage devices, or a series of laser pulses in a printer.
Because there are such wide differences in the hardware, there are differences in the way that the driver programs function. Most run when the device is required and function much the same as any other process. The operating system frequently assigns high-priority blocks to drivers so that the hardware resource can be released and readied for further use as quickly as possible.
One reason that drivers are separate from the operating system is so that new functions can be added to the driver — and thus to the hardware subsystems — without requiring the operating system itself to be modified, recompiled and redistributed. Many drivers are created or paid for by the manufacturer of the subsystems rather than the publisher of the operating system. That gives them the chance to update and enhance the input/output capabilities of the overall system.
Operating system publishers also create device drivers to update computers. While it is easier to expect up-to-date drivers for Windows and macOS from the large profitable companies that release them, Linux machines and other open-source OSes often rely on developers in their communities who are willing to volunteer their time and coding skills to provide drivers for systems and peripherals.
Managing input and output is largely a matter of managing queues and buffers, special storage facilities that take a stream of bits from a device — perhaps a keyboard or a serial port — hold those bits, and release them to the processor at a rate with which it can cope. This function is especially important when many processes are running and taking up processor time. The operating system instructs a buffer to continue taking input from the device, but to stop sending data to the processor while the process using the input is suspended. Then, when the process requiring input is made active once again, the operating system commands the buffer to send data. This process allows a keyboard or a modem to deal with external users or computers at a high speed even though there are times when the processor can't use input from those sources.
Managing all the resources of the computer system takes up most of the operating system's function and, in the case of real-time operating systems, may be virtually all the functionality required. For other operating systems, though, providing a relatively simple, consistent way for applications and humans to use the power of the hardware is a crucial part of their reason for existing.