Mark As Completed Discussion

Writing Files

The initial procedure of reading and writing files is the same, as the file needs to be found and opened in the program before any operation. Once the file system traverses through the files to find the desired file, the program issues a write() system call. A key difference between reading and writing files is that writing to a file may allocate additional blocks.

Mainly, writing to files occurs in three steps,

  • Reading the data from bitmap to locate the file (open() system call)
  • Updating newly allocated blocks by writing to corresponding bitmap and inodes.
  • Writing data on the actual allocated block.

As you may have observed, these operations are I/O expensive and may slow down the disk. To cater to this issue, most systems use the system memory and introduce caching and buffering techniques to reduce I/O overhead.