VDSO(7) 和 SYSCALL(2) 之间有什么关系?
What's the relationship between VDSO(7) and SYSCALL(2)?
从this post,我学到了
syscall
是在 x86-64
上进入内核模式的默认方式。
- 实际上,最近的内核正在实现 VDSO
然后我在http://man7.org/linux/man-pages/man2/syscall.2.html中查找手册:
The first table lists the instruction used to transition to kernel
mode (which might not be the fastest or best way to transition to the
kernel, so you might have to refer to vdso(7)), the register used to
indicate the system call number, the register used to return the sys‐
tem call result, and the register used to signal an error.....
但是我缺乏一些必要的知识来理解这些陈述。
VDSO(7)是syscall(2)的实现还是syscall( 2)会调用VDSO(7)完成系统调用?
如果不成立,VDSO(7)和SYSCALL(2)有什么关系?
VDSO(7) 不是 syscall(2) 的实现。
如果没有 VDSO(7),系统调用将在用户 space 应用程序中为 运行。在这种情况下会发生上下文切换。
如果使用 VDSO(7),将是 运行 没有上下文切换的系统调用。
内核使用 vDSO 自动映射到所有用户 space 应用程序的地址 space。
更仔细地阅读手册页 syscalls(2), vdso(7) and the wikipages on system calls and VDSO. Read also the operating system wikipage and Operating Systems: Three Easy Pieces(可免费下载)。
系统调用是基础,它们是 仅 方式 user-space application can interact with the operating system kernel and use services provided by it. So every program uses some system calls (unless it crashes and is terminated by some signal(7)). System calls requires a user to kernel transition (e.g. thru a SYSCALL
or SYSENTER
machine instruction on x86) 不知何故 "costly"(例如可能需要一微秒)。
VDSO 只是一个巧妙的优化(为了避免真正的系统调用的成本,对于像 clock_gettime(2) which also still exist as genuine system calls), a bit like some shared library magically provided by the kernel without any real file. Some programs (e.g. statically linked ones, or those not using libc
like BONES or probably busybox 这样的极少数功能)不要使用它。
您可以避免使用 VDSO(或不使用它),而早期的内核没有它。但是你无法避免进行系统调用,而且程序通常会做很多这样的事情。
还玩 strace(1) 以了解应用程序或 运行 进程完成的(许多)系统调用。
从this post,我学到了
syscall
是在x86-64
上进入内核模式的默认方式。- 实际上,最近的内核正在实现 VDSO
然后我在http://man7.org/linux/man-pages/man2/syscall.2.html中查找手册:
The first table lists the instruction used to transition to kernel mode (which might not be the fastest or best way to transition to the kernel, so you might have to refer to vdso(7)), the register used to indicate the system call number, the register used to return the sys‐ tem call result, and the register used to signal an error.....
但是我缺乏一些必要的知识来理解这些陈述。
VDSO(7)是syscall(2)的实现还是syscall( 2)会调用VDSO(7)完成系统调用?
如果不成立,VDSO(7)和SYSCALL(2)有什么关系?
VDSO(7) 不是 syscall(2) 的实现。 如果没有 VDSO(7),系统调用将在用户 space 应用程序中为 运行。在这种情况下会发生上下文切换。 如果使用 VDSO(7),将是 运行 没有上下文切换的系统调用。 内核使用 vDSO 自动映射到所有用户 space 应用程序的地址 space。
更仔细地阅读手册页 syscalls(2), vdso(7) and the wikipages on system calls and VDSO. Read also the operating system wikipage and Operating Systems: Three Easy Pieces(可免费下载)。
系统调用是基础,它们是 仅 方式 user-space application can interact with the operating system kernel and use services provided by it. So every program uses some system calls (unless it crashes and is terminated by some signal(7)). System calls requires a user to kernel transition (e.g. thru a SYSCALL
or SYSENTER
machine instruction on x86) 不知何故 "costly"(例如可能需要一微秒)。
VDSO 只是一个巧妙的优化(为了避免真正的系统调用的成本,对于像 clock_gettime(2) which also still exist as genuine system calls), a bit like some shared library magically provided by the kernel without any real file. Some programs (e.g. statically linked ones, or those not using libc
like BONES or probably busybox 这样的极少数功能)不要使用它。
您可以避免使用 VDSO(或不使用它),而早期的内核没有它。但是你无法避免进行系统调用,而且程序通常会做很多这样的事情。
还玩 strace(1) 以了解应用程序或 运行 进程完成的(许多)系统调用。