1
$\begingroup$

I'm guessing I could replace the words "hard drive" with "random access medium" but let's be more specific here. Also for the sake of this question, let's not consider SSDs. Just plain old hard-drives with heads and magnetic discs.

I'd guess that the hard drive doesn't care about things as bytes and receives instructions from the OS on about where to move it's head, but that'd assume that the OS has knowledge of sectors, cylinders or whatever physical properties of the drive and it's stored data so that doesn't feel right.

So, how does this work?

$\endgroup$
  • 2
    $\begingroup$ What reading did you do? This should be easily answerable with common resources such as Wikipedia. $\endgroup$ – David Richerby Sep 3 '15 at 11:09
  • 1
    $\begingroup$ Very loosely speaking, physical bits on the hard drive are indexed by an integer, and are naturally grouped into groups of 8 forming bytes. As for the operating system, I believe that it reads data from the hard drive in larger chunks, of entire sectors (usually 512 bytes); but this is just a guess. $\endgroup$ – Yuval Filmus Sep 3 '15 at 19:46
2
$\begingroup$

Simplified, the operating system sees disk storage as a randomly accessible set of sectors, each sector containing some fixed number of bytes. The OS asks the disk controller for a sector using some standard protocol and it is the responsibility of the disk controller to retrieve the sector with the bits and bytes in the same order in which they were written. The communication protocol (e.g. SCSI) specifies both bit and byte order for reads and writes so there is no space for confusion about where the data starts and stops.

Operating systems can and do take into account the characteristics of storage media for the sake of efficiency, such as existence of onboard cache, rotational delays, and head movement, but those things have no bearing on where bytes and sectors start.

$\endgroup$
  • $\begingroup$ So, if I understood correctly, both the OS (say, the driver) and the Controller-HDD system have knowledge of sector properties. The OS knows what sector contains the required data and the Controller-HDD system knows where this sector is located. After the sector is read and sent to the OS and then even counting bit by bit to find the beginning of each byte shouldn't be too expensive. Sounds really simple now $\endgroup$ – Loupax Sep 4 '15 at 9:30
  • $\begingroup$ That is correct. $\endgroup$ – Kyle Jones Sep 4 '15 at 22:44
-1
$\begingroup$

I think that you should first bear in mind that computer architecture is based on the mechanism of abstraction in order to make it easier, for instance, to manage and access data, and avoid the hurdle of having to take care of the specific hardware that needs be accessed.

Having said that, you can understand that the OS itself can't be allowed, also for efficiency reasons, to make distinctions between an USB or an hard disk access and so on. This premise is to confute the fact that the hard disk "doesn't care about bytes" and that the resolution of the data address is all on the OS. In fact, the hard disk DOES have an internal controller and circuitry that needs to identify and translate the address that the OS requests in the number of disk, cylinder and sector, the xyz coordinates in HD technology. The operating system instead interfaces with a file system that is built based on the disk content, without overweighting it with more "circuitry matters"

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.