multithread read from disk?

后端 未结 5 1071
青春惊慌失措
青春惊慌失措 2020-12-17 10:55

Suppose I need to read many distinct, independent chunks of data from the same file saved on disk.

Is it possible to multi-thread this upload?

Related: Do al

5条回答
  •  半阙折子戏
    2020-12-17 11:35

    Multiple reads from a disk should be thread-safe by the design of the op system if you use the standard system functions there's no need to manually locking it, open the files read-only though. (Otherwise you'll get file access errors.)

    Btw you are not necessary reading from the disk in practice, the op system will decide where it will serve you from. It typically prefetches the reads and serves from the memory.

提交回复
热议问题