问题
I'm trying to piece together how these four things work together:
1)Assembly is the language which talks directly to hardware, there is no other language between Assembly and voltages on pins.
2)The Kernel of an OS is a set of Assembly functions that the OS uses.
3)An OS makes functions available to Applications (system calls?), the system calls then utilize the Kernel to do stuff. (Like if you're trying to reduce the scope of some code by wrapping it up in an object or function (JS background). The OS wraps up the Kernel).
My Question:
4a) Applications compile to OS functions?
4b) Applications compile to Assembly? And if so, then what is the purpose of the OS?
Side-question:
Are 1) through 3) correct?
回答1:
1) Assembly language (typically "plain text") is converted into a different language (machine code) by an assembler. Machine code is what the CPU itself executes. The CPU may convert machine code into a different language (e.g. micro-ops) before/during executing it.
2) The kernel of an OS is machine code; where the original language used (source code) may have been assembly or C or C++ or anything else before it was converted into machine code by a compiler.
3) Most kernels do provide a "function like" interface that processes (applications) can use; but this isn't a strict requirement and nothing really prevents a kernel from using a "not function like" interface (e.g. maybe based on packets or messages of streams) instead.
4a) Processes (applications) typically use system libraries, where the system libraries use the kernel's API. This isn't a strict requirement either. For example; a process may use the kernel's API directly without a system library (with some loss of portability between similar but different kernels).
4b1) Processes (applications) are typically compiled to machine code. This is also not a strict requirement - e.g. a kernel might interpret byte-code or something (Lisp machines).
4b2) The term "operating system" isn't well defined, and neither is its purpose (different people have different definitions, etc). I personally consider the main purpose of OS to be providing convenient abstractions; so that every process (application) doesn't have to include a device driver for every possible device, and can just use nice abstractions (to open/read/write files, send/receive packets over a network, etc) instead.
Note: An application is only one kind of process, other types of process include utilities, daemons, servers, services, and (for micro-kernel systems) device drivers, file systems, etc.
来源:https://stackoverflow.com/questions/33793506/os-kernel-applications-and-assembly