在用户模式 linux (UML) 中,跟踪线程取消用户空间进程进行的系统调用,并将它们重定向到在用户空间中运行的内核。现在在某个时候这个用户空间内核需要主机操作系统的帮助。用户态内核如何调用底层宿主机内核,是否只是普通的系统调用?或者它是否使用某种 IOCTL 机制或其他方式?
最佳答案
我找到了一个非常简单的 UML 设计解释 here .它可能对您有用。
UML constructs it using ptrace system call tracing mechanism.
- When a process in user space, its system called are intercepted by ptrace.
- When it is in the kernel, no interception. When a process executes a system call or receives signal, the tracing thread forces the process to run in the kernel.
- After the transition, the process state is restored and it continues.
System call virtualization
- By switching the user and kernel and system calls interception
- Note: the system call must be annulled in the host kernel.
- The process state is preserved.
- When the system call is complete, the process obtains the returned value in its saved registers and returned to user mode.
另外,这篇文章解释了 System call virtualization using ptrace如下图。
http://www.csee.wvu.edu/~katta/uml/graphics/vsyscall.jpg .红线代表正常的系统调用过程。
关于c - UML 中的用户模式内核如何与主机上的底层内核接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32303095/