System call vs Function call

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

    Actually, the system call is not related to function call. The only common of these two mechanism is that they both provides services to the caller.

    • From view of thread execution to see system call:

      A system call is function for application mode program to request services provided by underline OS. The system call will bring the running thread from user mode into kernel mode, execute the system call handler function, then return back to user mode.

    • Syscall Parameters:

      The parameter of a system call is (syscall number, params...). The meaning and format of params depends on syscall number.

    • From view of syscall library provided to userland program:

      The user mode program usually calls glibc's library to call system call. For example, the open() function in glibc:

      1. put system call number SYS_OPEN in eax register
      2. request system call by calling a software interrupt or sys_enter instruction

提交回复
热议问题