Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Something about the operating system kernel

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

one。 In general, the operating system only needs to achieve the following two points:

1. The illusion of time and space

The function of time illusion is to realize multi-process / multi-thread, and the function of space illusion is to realize virtual memory. There is no doubt that these two points are the cornerstones of modern operating systems.

two。 Interface with hardware and user mode

Receive information from the hardware, this is implemented with interrupts, and the hardware reads and writes each other, this is implemented with basic IO; requests are received from the user, and this is implemented with system calls. Send a message to the user, which uses a signal. There is no doubt that this meets the requirements of the upper users and the underlying hardware at the interface level, and there is no doubt that UNIX is successful at this point (signal, IPC,POSIX...).

two。 Large kernel and microkernel

If we divide the operating system kernel according to time in the early stage of its life cycle, we divide it into the source phase and the binary stage. The distinction between the large kernel and the micro kernel is the binary stage. We all know that Linux is a big kernel, but why is it big and not messy? In fact, look at its source code to understand, its source code is very well organized, less than 100 core files, the rest are driver or architecture-related code. After all, developers know that binaries are incomprehensible to people, and what they look at is the source code. Separating the binaries will undoubtedly increase the complexity of maintenance, not to mention that keeping the problem in the source phase saves a lot of debugging time.

three。 Device driver development

1. Read datasheet, write IO, interrupt routines

two。 Interface with the operating system kernel, that is, insert the lowest end of the kernel

3. And user mode interface, that is, export a user interface at the top, such as ioctl

4. Write user-mode demo and tool processes, and call the interface in step 3

5. Trial, debugging and packaging

6. Summary, hierarchy-from top to bottom: end user-application programmer-system programmer-driver programmer-hardware engineer

four。 Whether fork should be solved in the kernel or not.

Fork is notorious. A bunch of seemingly garbled characters can deplete your cpu:. () {. |. &};. If you want to solve it in the kernel, it is very simple, that is, to control the number of layers of task_struct. We know that the Linux process is organized in a hierarchical tree. If the number of layers is limited to 5 layers at most, then it will not work if it is exploded five times at most. However, this is not a good method, because it will damage the interests of normal programs that happen to need 6 or more layers. In fact, there are many solutions: 1. Use cpu group scheduling to limit the resources they can use; 2. Modify oom killer's core algorithm to give priority to cutting off branches that are too long but very thin, which is also in line with the way gardeners operate, because these branches will take away too much nutrients!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report