1

Say I need to create and save the file data on HDD. HDD is nothing but a stack of multiple spinning disks. My understanding is file data is divided in to number of memory blocks which can be saved to any disk(among stack of disk in HDD) in HDD. Is that correct ?

Another related question is say two write or two read request are executed at exactly same time. Will they be done sequentially where once one task is executed then only next task will be executed or each request will be executed in round robin fashion for some time interval ?

1
  • RE 2nd question: The OS and the organization of the actual files affect the I/O requests. If a file is composed of contiguous LBAs (i.e. not fragmented), then a single disk request for multiple LBAs could be issued instead of several requests.
    – sawdust
    Apr 7, 2019 at 22:37

1 Answer 1

1

Say I need to create and save the file data on HDD. HDD is nothing but a stack of multiple spinning disks. My understanding is file data is divided in to number of memory blocks which can be saved to any disk(among stack of disk in HDD) in HDD.

The operating system doesn't see individual disk platters – it only sees the whole HDD as a single linear storage device, which is only accessible using "logical block addresses" (LBAs).

Usually the lowest-numbered LBAs (starting from 0) are on the outer edge while highest-numbered LBAs are on the center – but the OS doesn't have information about where physically (e.g. on which disk platter) the data is located. Only the HDD's firmware knows this. (I think it's generally some sort of round-robin mapping?)

(The same applies to flash-based SSDs or USB sticks – the OS sees a single storage unit, and the SSD itself decides how to place each LBA to the corresponding flash chip.)

So when the OS needs to save a file,

  1. first the OS file system divides the file into blocks and decides on which LBAs to store the file at (usually the same file's blocks are kept close together, but different files are scattered around);

  2. then the HDD decides which platter/track/sector to use for each LBA.

Another related question is say two write or two read request are executed at exactly same time. Will they be done sequentially where once one task is executed then only next task will be executed or each request will be executed in round robin fashion for some time interval ?

This depends on the operating system's I/O scheduler. See e.g. this PDF.

The scheduler might also change its logic depending on the device type (e.g. spinning disks have "seek time" delays, but flash memory doesn't), on whether the device supports queued requests (e.g. SATA AHCI supports sending multiple requests at once, but IDE practically doesn't), and other factors.

7
  • Can you please look at superuser.com/questions/1421663/… as well ? Apr 7, 2019 at 12:12
  • Question on second query . Be it sequential or round robin , can read or write be parallel operation ? I think parallelism should be possible when read/write happening on different platter/disk of same HDD as there will separate actuator head for each disk but parallelism won't be possible when happening on same platter/head ? Apr 7, 2019 at 12:50
  • Actually all platters rotate together and all heads use a single actuator and move together, so it's physically impossible to do a parallel read from different tracks or differently located sectors. (Only very new enterprise-class HDDs might have separately moving heads, e.g. Seagate only recently announced that it will start selling multi-actuator disks in ~2019.) Apr 7, 2019 at 13:11
  • 1
    "then the disk may read from both platters in parallel" -- No, that is not done, unless there's an unusual drive out there that has multiple reader logic. A conventional HDD selects one head to use for reading or writing, and the ancillary hardware such as the sector buffer and ECC generator/validator support that selected R/W head.
    – sawdust
    Apr 7, 2019 at 22:31
  • 1
    @grawity -- Take that *"dual actuator" marketing hype with a big dose of salt. It's just equivalent to two drives in one enclosure and using one spindle motor. Each platter surface still only has a single R/W head. The claims of "parallelism" seem inflated IMO. What you really want is a dual-ported drive. That would give you two R/W heads per surface!
    – sawdust
    Apr 7, 2019 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .