System call vs Function call

后端 未结 10 707
遥遥无期
遥遥无期 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

    System call actually calls out to an API executed by the kernel space. With all the associated costs this assumes (see Wiki, or this link for details)

    A function call is a call to a piece of code in user space.

    However, please note that a function call MIGHT be to a function which in the process of its execution does system calls - "fopen" being one of such examples. So while the call to fopen itself is a call to a function, doesn't mean that the system call will not happen to handle the actual IO.

提交回复
热议问题