Lkd 3rd reading notes -- Chapter 1st/Overview of operating system and kernels

Source: Internet
Author: User

Overview of operating systems and kernels

Due to the increasing features of operating systems and the irrational design of some commercial operating systems, the concept of accuracy of operating systems is unknown. Many users think that what they see on the screen is the operating system. From a technical point of view, in this book,Operating SystemIt refers to the part responsible for the basic operations and management of the entire system. Includes kernel, device driver, boot program, command shell, other user interfaces, and basic file and system tools. WhileSystemIsOperating SystemAndAll applications:

System = operating system + application

 

Of course, the topic of this book is the kernel. The user interface is the outermost layer of the operating system, while the kernel is the innermost layer. The kernel provides basic services, manages hardware, and allocates system resources to other parts of the system. The kernel is also known as the supervisor, core, or internals of the operating system ). The kernel is usually composed of the following parts: the process scheduler responsible for processing interrupt requests, the process scheduler responsible for allocating CPU time between multiple processes, the memory management system responsible for managing the process address space, and system services (such as network services and inter-process communication ). In a modern operating system with memory protection mode, the kernel usually resides in a higher system state than a user program. This status includes protected memory space (that is, the user program cannot access the memory) and full access to the hardware. This system status and memory space are called kernel space. Therefore, when user programs are executed in user space, they can only see a subset of available machine resources and can only execute specific system functions. They can directly manipulate hardware or access memory not allocated by the kernel, is illegal. When executing the kernel code, the system runs in the kernel spaceKernel stateWhen running a regular program, the system runs in the user spaceUser status.

The application communicates with the kernel through system calls, as shown in Figure 1.1 ). Applications call functions through libraries, for example, C libraries, and database functions notify the kernel to execute specific tasks on behalf of user programs through System Call interfaces. Some library functions have many functions that are not available for system calls. Therefore, triggering a system call is only one step of some large library functions. For example, consider the familiar printf () function, which provides the functions of formatting and caching data (not available for system calls), and it uses the system to call write () writing data to the console is only one step of the function. On the contrary, some library functions have a one-to-one relationship with system calls. For example, the C library function open () is a simple encapsulation of the system call open. In addition, some library functions, such as strcpy (), do not call the kernel at all.When a program executes a system call,We call it:The kernel indicates that the application is being executed,Further, an application is called:Executing a system call in the kernel space,This is called:The kernel runs in the process context ).

 

The kernel is also responsible for managing system hardware. Almost all hardware architectures, including those supported by Linux, have the concept of interruptions. When the hardware wants to communicate with the system, it sends an interrupt request to the system, which is first sent to the CPU and then forwarded to the kernel. Each interrupt is identified by a specific number. The kernel finds the corresponding interrupt handler based on the number and executes them to respond to the interrupt request. For example, when you press the keyboard, the keyboard controller sends an interrupt request to let the system know that there is new data in the keyboard buffer, and the kernel notices the interrupt number of the new interrupt request, then, execute the correct interrupt handling program based on the interrupt number. The interrupt handler processes the keyboard data and notifies the keyboard controller that it is ready to process more data. To provide synchronization operations, the kernel can disable interruption, including disabling all or only a specific interruption. In many operating systems, including Linux, the interrupt handler does not run in the process context, but runs in a specialInterrupt Context)Is not associated with any process. This special context is used to make the interrupt handler run faster and then exit.

 

These contexts reflect the scope of kernel activity. In fact, in Linux, we can conclude that each processor is in one of the following three transactions at any point in time:

1. In the user space, run the user code in the process 2. In the kernel space, in the process context, it indicates that the process executes a system call. 3. In the kernel space, in the interrupt context, response to an interruption independent of any process

 

The above list is complete, and examples of any corner meet these three transactions: for example, when the processor is in the idle state (idle, the kernel runs the idle process in the kernel space and process context.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.