What are the advantages of pwrite and pread over fwrite and fread?

前端 未结 3 1265
温柔的废话
温柔的废话 2021-02-05 05:24

Hey please don\'t mind if I am asking trivial question, but, please can somebody help me with this..

3条回答
  •  醉话见心
    2021-02-05 05:40

    It's useful when you do a lot of random read/write operations. There is even an option for SQLite3 that replaces seek() + read() and seek()+ write() with pread()/pwrite().

    The advantage: seek()+ read() and seek() + write() both are the pairs of system calls while pread() and pwrite() are single system calls. It's usually an universal truth that the less system calls program issues the more efficient it is.

提交回复
热议问题