Home » Questions » Computers [ Ask a new question ]

Are flash drives and hard drives thought of as "an ocean of bytes"?

Are flash drives and hard drives thought of as "an ocean of bytes"?

Why can a USB Flash drive be formatted as NTFS or FAT32? Is the USB Flash Drive and Hard Drive just to be thought of as "an ocean of bytes"?

Asked by: Guest | Views: 58
Total answers/comments: 1
Guest [Entry]

"You can, but operating systems can't. Both the flash drives and hard drives are read (and written) by sectors and only sectors. The device driver usually applies this restriction to the higher level, and also reading whole sector with e.g. NTFS superblock is much more faster than reading the same sector several times implicitly because of a driver that translates ""byte range"" requests to ""sector"" requests, so filesystem drivers are also performing read and write operations by sectors (or any multiplies of sectors: there exists a technology called DMA -- direct memory access -- that allows reading and writing large bursts of sectors without using CPU time thus making disk access very fast).

Flash chips (not drives) are technically divided on other blocks of data because of two reasons:

Flash chips can be read from any position to any position but written only by fixed sized and positioned blocks.
Flash chips contain both more data and free space than you think because it is normal for a chip to gain some failed sectors during work. They are remapped to other sectors by storage controller on USB drive and are not visible for OS as bad sectors; there is actually no software way to check if they exists. Again, flash memory controllers are always equipped with algorithms that allow seamlessly replace failed sectors without any notice for upper layers.

The NTFS doc you are reading does not suggest reading those variables by bytes. You need to read them in whole sectors they contained in, and then address a particular byte in memory.

Also recent memory (virtually any on a 386-compatible machine) is not addressed by bytes. Instead it is addressed by 32- (rarely), 64- and even 128-bit words. And when you are reading a byte in a middle of such word processor really requests the whole word and then selects byte you need. There is even a hardware exception on some 64-bit processors that raises when you try to access an unaligned (by the 64-bit word boundary) pointer."