Can a conventional HDD perform both random and sequential access ?
A HDD is categorized as a random-access device. The sectors of the HDD are addressable, and a read or write operation requires specification of a sector address. A R/W operation does not depend on the location of the previous operation.
A sequential-access device, such as magnetic tape (reel or cartridge) and punched (paper or Mylar) tape, do not have addressable records or blocks. The records/blocks are position dependent, and read/write access has to start at the beginning of the medium. There are some tricks (e.g. file marks on mag tape) to allow high-speed searching, but sequential-access devices nowadays primarily exist because of data retention and cost-per-byte advantages. With the modern proliferation of HDDs and SDDs, sequential-access devices fail to deliver performance as a general-purpose storage device (e.g. for a filesystem).
If so why would you want to keep provisions for both ?
Sequential access is a natural capability of a random-access device.
Whereas a sequential-access device struggles (i.e. requires a lot of additional operations and consumes time) to perform random access.
Technically a HDD does not perform sequential access. The command interface does not have a "read next" or "write next". An explicit sector address must be specified.
After reading this post I am getting the idea that sequential access is better than random access, how is that so ?
Better in what way?
(BTW those answers are not 100% accurate.)
Some applications (e.g. a data recorder/logger or archiving a HDD) perform perfectly well with sequential access, and would not benefit at all using random access.
Some applications absolutely require random access in order to accomplish their task in a timely manner (e.g. database query or a filesystem).
Note that the typical PC has no sequential-access storage device.
In general, a random-access device has more utility than a device limited to sequential access. That's why the HDD (or SDD) (which are both random-access devices) are essential peripherals for computer mass-storage, whereas sequential-access devices such as tape are considered optional and relegated primarily to archival functions.
So random access provides all the facilities of sequential access.
Correct.
Also under which situations will a HDD resort to random/sequential access ?
The HDD, because of its command interface, always performs a random access.
In order to access the "next sequential" sector, the host computer must request the "previous sector + 1"; there is no command to "read (or write) next". Every R/W command must specify a sector address.
Note that the operating-system filesystem software will obscure this HDD trait. Most files are accessed sequentially: you start writing or reading a file at its beginning, and continue accessing the file one record or line at a time (i.e. sequentially). Copying a file is always performed by reading the source file sequentially. But study this answer to understand how the filesystem and HDD have to perform additional random accesses to accomplish this sequential copying of file contents.
How type of I/O access influences access time?
First we need to properly define HDD "access time" (since answers in that post you mentioned are inaccurate). There are several components to access time that correspond to a HDD operation:
- The read or write command has to be sent from the host computer to the HDD over the host-to-drive interface (e.g. SATA).
- The HDD controller processes the command. If a read request can be satisfied from the cache, then the sector data is already available; goto step #8. For a write request the sector data also has to be sent over, and then ECC bytes are calculated.
- The actual disk operation would commence with an optional seek operation.
If the R/W head assembly is not already positioned at the requested cylinder, then a seek operation must be performed. The time interval to perform this R/W head movement operation is called the seek time.
Note that the seek (i.e. the movement of the R/W heads) requires acceleration, an optional phase of max velocity and then deceleration. The speed is not constant, and seek times are not linearly in proportion to the number of cylinders traversed. These facts make most short-stroke calculations bogus.
If the R/W head assembly is already positioned at the requested cylinder, then no seek is required and the seek time is effectively zero.
- Once the R/W head assembly is at the requested cylinder, the R/W head corresponding to requested track is selected.
- As the platters rotate "beneath" the R/W heads, the controller has to wait for the requested sector to come around. This waiting time is called the rotational latency. Unless you can predict when the controller starts the wait in relation to the rotational position of the requested sector, the average rotational latency is one half the rotation period. (The period is the inverse of rotational speed.)
- Once the requested sector is located, the actual read or write operation is performed. For a read operation, the bits read off the platter surface are written as bytes into a sector buffer. For a write operation, the data in the sector buffer are serialized and written to the platter surface.
- Once the entire sector has been read into the sector buffer (of the controller), the data is validated using the ECC. Correction is applied if necessary (a soft error). If the errors cannot be corrected, then a read retry is attempted.
- The R/W request is concluded by responding to the host computer with the sector data that was read or a "write OK" acknowledgement over the host-to-drive interface.
The access time would be the total elapsed time to perform all of these operations. Except for #3, seek time, and #5, rotational latency, the other operations tend to have relatively short and predictable durations in comparison to those two operations.
A random HDD access would tend to have a long access time because a seek of unknown span and a rotational latency would be required.
A sequential HDD access could have a minimal access time because no seek is likely (unless the previous access was the last sector of the cylinder) and rotational latency could be zero if the request was already queued up or the previous read performed "read ahead". If the timing of sending sequential requests to the HDD is poor (i.e. too late, missing the next sector), access times would be increased due to the rotational latency equal to a near-full rotation time. That latency would be about the same magnitude as a seek of one cylinder.