操作系統
An operating system is a software controlling the operation of a computer system and its resources. Major functions of operating systems may include:
操作系統是一個控制計算機系統操作和資源的一個軟件。主要功能:
Managing memory and other system resources.
管理內存和其他資源Imposing security and access policies.
管理安全和訪問機制Scheduling and multiplexing processes and threads.
調度運行多進程和多線程Launching and closing user programs, and providing basic system services for them.
啟動關閉用戶程序,并且提供基本的系統服務Providing a basic user interface and application programmer interface.
提供基本的交互以及api接口
Not all operating systems provide all of these functions. Single-tasking systems like MS-DOS would not schedule processes, while embedded systems like eCOS may not have a user interface.
——osdev.wiki
what is a kernel
The kernel of an operating system is something you will never see. It basically enables any other programs to execute. It handles events generated by hardware (called interrupts) and software (called system calls), and manages access to resources.
The hardware event handlers (interrupt handlers) will for instance get the number of the key you just pressed, and convert it to the corresponding character stored in a buffer so some program can retrieve it.
The system calls are initiated by user-level programs, for opening files, starting other programs, etc. Each system call handler will have to check whether the arguments passed are valid, then perform the internal operation to complete the request.
Most user programs do not directly issue system calls (except for asm programs, for instance), but instead use a standard library which does the ugly job of formatting arguments as required by the kernel and generating the system call. (For example, the C function fopen() eventually calls a kernel function that actually opens the file.)
The kernel usually defines a few abstractions like files, processes, sockets, directories, etc. which correspond to an internal state it remembers about last operations, so that a program may issue a session of operation more efficiently.