Reputation: 11
What are some of the challenges that are faced by an operating system when there are multiple devices working simultaneously and what can be used to help determine the order in which these devices are handled?
Upvotes: 0
Views: 263
Reputation: 37252
For device drivers and devices, typically (as a basic/simplified model):
The important part here is that the device driver only uses a tiny amount of CPU time to manage the device (while the device spends most of its time doing what it's told to do without using any CPU); and almost all of the CPU's time can be spent doing other things (including spending a little time to manage many other devices and a lot of time running normal user-space code). This means that many different devices can be doing useful things simultaneously, while CPU/s spend most their time executing normal code.
Typically there are only 2 things that manage the order. The first is how the device driver's "queue of pending jobs" is designed. It can be a simple "first come first served" FIFO queue; but often it's something more complex involving "IO priorities" (e.g. to ensure that reading urgently needed data from swap space occurs before prefetching data that isn't actually needed yet from the same device).
The second thing used to manage the order is IRQ priorities (for when multiple devices generate an IRQ at the same/similar time). This can be either "first come first served" (nothing managing the order that IRQs are handled), or can involve hardware support and OS cooperation.
WARNING 1: This was a basic/simplified model. In real systems there are more complications (e.g. jobs that are already on a device driver's "queue of pending jobs" can be cancelled, device driver has to do power management, device may be unplug-able, etc); and some devices have their own internal queues and/or are able to perform multiple jobs simultaneously themselves.
WARNING 2: This was "typical for a modern OS". Operating systems are different, and some (e.g. MS-DOS from 30 years ago) might do none of the above (and might not allow multiple devices to be used simultaneously at all).
Upvotes: 2