系统调用和指令集有什么区别

What is the difference between system calls and instruction set

我很困惑系统调用和指令集是否同义? MOV、LOAD、CALL、IN、OUT、ADD、SUB等指令是否属于系统调用? open()、close()、read()、write() 等系统调用指令。如果不是那么他们之间是什么关系。有人可以解释一下并消除混淆。

需要几本书才能解释其中的区别。我特别推荐Operating Systems : Three Easy Pieces and some book on computer architecture, or at least some slides on the fictitious Y86 instruction集。

一个instruction set architecture defines the machine code understood by some processor and how every machine instruction changes the (observable) state of the computer (e.g. changes content of processor registers -including the program counter and the call stack pointer, memory locations in virtual address space,等等...)

一个system call是一些应用程序向操作系统内核请求服务。从应用程序的角度来看,这通常是一条基本的机器指令(例如 SYSENTERSYSCALL),但内核在返回之前会 运行 大量代码(在内核内部)到应用程序。

换句话说,一个操作系统kernel provides the application process the illusion that the processor understands ordinary unprivileged machine code augmented by a system-call primitive (able to run any of the syscalls provided by the kernel; for Linux see syscalls(2) for an exhaustive list). Read also about SYSENTER in Linux and SYSENTER on OsDev

重点是各种CPU modes some privileged machine instructions (e.g. those accessing peripherals or the MMU)只允许内核使用。如果您的应用程序代码尝试它们,处理器会引发一些异常。

我们从用户space调用到内核的函数是调用系统调用

一个指令集是一组机器码指令,可以被CPU(C中心 P 处理 Unit).

说明:- 始终执行单个任务。

系统调用:- 它是一组指令,全部由系统可识别的单个名称调用,称为系统调用。