系统调用和指令集有什么区别 [英] What is the difference between system calls and instruction set

查看:63
本文介绍了系统调用和指令集有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Iam confused whether system calls and instruction set are synonymous? Do the instructions like MOV, LOAD, CALL, IN, OUT , ADD, SUB etc fall in the category of system calls? System call instructions like open(), close(), read(), write(). If not then what is the relationship between them. Can someone please explain and clear the confusion.

推荐答案

需要几本书来解释差异.我特别推荐 Operating Systems : Three Easy Pieces 和一些关于计算机体系结构的书,或者至少是虚构的Y86指令集上的一些幻灯片.

Several books are needed to explain the difference. I recommend notably Operating Systems : Three Easy Pieces and some book on computer architecture, or at least some slides on the fictitious Y86 instruction set.

指令集架构定义了机器代码被某些处理器理解,以及每条机器指令如何改变计算机的(可观察的)状态(例如改变处理器寄存器 - 包括 程序计数器调用堆栈指针, 记忆 locations虚拟地址空间等...)

An 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, etc...)

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

A system call is done by some application program to request services from the operating system kernel. From the application program's point of view, that is often an elementary machine instruction (e.g. SYSENTER or SYSCALL) but the kernel will run a big lot of code (inside the kernel) before returning to the application program.

换句话说,操作系统 kernel 为应用进程提供了幻觉处理器理解由系统调用原语增强的普通非特权机器代码(能够运行内核提供的任何系统调用;对于 Linux,请参见 syscalls(2) 以获得详尽的列表).另请阅读 Linux 中的 SYSENTEROsDev 上的SYSENTER.

In other words, an operating system 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 模式中,一些特权机器指令(例如那些访问外围设备的指令)或 MMU) 仅允许内核使用.如果您的应用程序代码尝试它们,处理器会引发一些异常.

The point is that with various CPU modes some privileged machine instructions (e.g. those accessing peripherals or the MMU) are only permitted to the kernel. If your application code tries them, the processor would raise some exception.

这篇关于系统调用和指令集有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆