System call vs Function call

后端 未结 10 691
遥遥无期
遥遥无期 2020-12-04 14:27

What is the difference between a system call and a function call? Is fopen() a system call or a function call?

10条回答
  •  失恋的感觉
    2020-12-04 15:15

    fopen is a function call.

    A system call interacts with the underlying OS, which manages resources. Its orders of magnitud more expensive than a function call, because many steps have to be taken to preserve the state of the process that made the syscall.

    On *nix systems, fopen wraps open, which makes the system call (open is the C - wrapper for the syscall). The same happens with fread /read, fwrite / write , etc..

    Here there's a nice description of the tasks executed by a unix syscall.

提交回复
热议问题