Difference between User vs Kernel System call

南楼画角 提交于 2019-12-13 06:32:20

问题


A system call is how a program requests a service from an operating system's kernel.

They can occur in user-mode and kernel-mode.

What are differences?

For example:

  • Overhead
  • System time

回答1:


A system call is the way you transition between the application ("user mode") and the kernel.

Syscalls are slower than normal function calls, but newer x86 chips from Intel and AMD have a special sysenter/syscall opcode to make it take just a hundred nanoseconds or so, give or take.




回答2:


@Leo,

Could you elaborate on how system calls vary when made from within kernel space? For better understanding of the Linux kernel, which is written in C and assembly

Notice, that system calls are just an interface between user space and kernel space. When you need some computer resources (files, networks, ...), you ask the kernel to give it to you (under the hood you ask the kernel to run kernel code, that is responsible for it).

Overhead of system calls is that you need to perform a CPU interrupt. As Will mentioned the time for it is very depends of a CPU type.



来源:https://stackoverflow.com/questions/23846097/difference-between-user-vs-kernel-system-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!