Difference between write() and printf()

后端 未结 6 1834
春和景丽
春和景丽 2020-12-09 04:03

Recently I am studying operating system..I just wanna know:

What’s the difference between a system call (like write()) and a standard library function (like printf()

6条回答
  •  被撕碎了的回忆
    2020-12-09 04:49

    I'd like to mention another point that the stdio buffers are maintained in a process’s user-space memory, while system call write transfers data directly to a kernel buffer. It means that if you fork a process after write and printf calls, flushing may bring about to give output three times subject to line-buffering and block-buffering, two of them belong to printf call since stdio buffers are duplicated in the child by fork.

提交回复
热议问题