0

I was just going through section 5.3 of Operating Systems: Design and Implementation: "File system implementation", and I have a doubt regarding disk management using linked lists (table implementation).

The authors mention that using the table implementation takes up 3 bytes per table entry, and this is understandable. However, it is also mentioned that an optimization for time can be performed by using 4 bytes per table entry.

How does that optimization work?

Mat
  • 202,337
  • 40
  • 393
  • 406

1 Answers1

2

Perhaps 4 bytes is the word size of the architecture, so the CPU can immediately do arithmetic with those values? With 3 byte values, you presumably need to do some bit twiddling to expand them to 4 bytes before you can operate on the values.

That being said, CPU's are very very fast compared to memory, not to mention disk, bandwidth, so I wouldn't be surprised if the 3 byte version is faster in practice.

janneb
  • 36,249
  • 2
  • 81
  • 97
  • I've been looking at the System V (and earlier) traditional UNIX file systems, and the list of addresses kept in the inode is a 40 byte character array, of 3-byte addresses. When the inode is read into memory, one of the first things that is done is expanding it to an in-memory array of 32 bit values that can be used normally. In the context of an i/o, the expansion is cheap, and the savings in the inode are worth the trouble. Not in the age of 6TB disks and 8k blocks, though. – dbrower Jan 23 '16 at 01:11