Queuing order
Magnetic hard drives perform faster such requests, the data of which lie closer to the read head
Yes, it allows you to more effectively use the movement of the head on the disk. Such actions, for example, implements the NCQ hardware algorithm, because why turn the head 500 times, sequentially turning over the queue, when can we take the data that is closer? This minimizes the number of head movements and the waiting for the desired sector on the track. There are hardware algorithms and software implementation algorithms for ordering.
Real life example
Passengers get into the elevator on the first floor and press the floors they need, the elevator goes sequentially according to the number of floors, not distinguishing the difference between the one who pressed the first or the last, effectively serving the current queue. And if he served first those who pressed the first, imagine how many extra kilometers would the elevator be winding? First at 6, then at 2, and so on.
You'd be surprised, but there are I / O controllers that can combine your two requests into one , but you won't even know about it. The I / O manager does everything to optimize the work time for the request and the number of work performed.
Hard disk and operating system
The input-output system is multi-level. All your requests are serviced by an I / O manager that creates a special structure (for example, on Windows, this is an IRP), which directs requests to the file system driver, and that directs requests to the hard disk driver, which works with the controller, which in turn works with a magnetic head.
Your request is transferred to the hard disk, what next? When your request has been processed by the hard disk, it generates an interrupt that is processed by the interrupt handler for the device, the device driver writes data to the system memory, and notifies the I / O manager that the data has been saved, but now you need to somehow send the data to the caller. flow so that it can copy its results to a buffer in the address space of its process.
The I / O manager knows the ID of the process that requested this data, it accesses the process address space and writes data from system memory to the process's virtual address space and notifies the process (for example, using a callback function or an alarm) that the data transfer complete and free all associated structures.
PS The description of the work of the I / O subsystem is very well described on various resources, although there are long articles describing them on the example of the operating system, here is a good description based on Windows.