Does a C/C++ program run the CPU or on the Kernel?

独自空忆成欢 提交于 2019-12-12 09:05:39

问题


I'm programming for quite some years now, but there's one thing that I never understood exactly:

There are 2 types of programming languages. Compiled ones and interpreted ones, while compiled ones first need to be to compiled to a interpreted language, before they can be executed.

For example, C/C++ needs to be compiled to machine language first, before it can be executed.

And here comes my question: Who does actually run a compiled C/C++ Windows/Linux program? Is it interpreded by the CPU directly, or does the OS Kernel execute it and pass the commands to the CPU?

And if the CPU executes it directly, how can the Windows Kernel then deny some calls? Otherwise, does it mean that the Kernel understands machine language as well, or do non-kernel C/C++ programs not compile to machine language?


回答1:


The program runs on the CPU. The CPU has different levels of privilege, so called "privileged instructions" may only be executed by the kernel - that's how security is enforced by the operating system.



来源:https://stackoverflow.com/questions/23338684/does-a-c-c-program-run-the-cpu-or-on-the-kernel

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