The basic architecture of Linux kernel and GNU / Linux operating system

Linux server development 2020-11-11 16:41:03
basic architecture linux kernel gnu

1. Linux Introduction to the kernel

kernel : In computer science, it is used to manage the data sent out by software I/O( Input and output ) The required computer program , Transfer these requests to Translated into data processing instructions and handed over to the central processing unit (CPU) And other electronic components in the computer , Is the most basic of modern operating systems Part of . It is part of the software that provides secure access to computer hardware for many applications , Such visits are limited , And it's up to the kernel to decide When and how long does a program operate on a piece of hardware . Direct operation on hardware is very complicated . So the kernel usually provides a kind of hardware Abstract methods , To do this . Through inter process communication mechanism and system call , The application process can indirectly control the required hardware resources ( special It's the processor and IO equipment ).

2. GNU/Linux Operating system and Linux Kernel relations

What we usually say Linux It's actually the kernel , namely Linux kernel . and Linux The operating system is actually GNU/Linux operating system , That is to use Linux Kernel GNU System .

3.GNU/Linux The basic architecture of the operating system

3.1 User space

At the top is the user ( Or applications ) Space .

This is where the user application is executed . Under user space is kernel space ,Linux This is where the kernel is .GNU C Library (glibc) Here, too . It provides a system call interface to the kernel , It also provides conversion between user space applications and the kernel The mechanism of . This is very important , Because kernel and user space applications use different protected address spaces . Process per user space All use their own virtual address space , The kernel takes up a separate address space .

3.2 Linux The architecture of the kernel

Kernel is the core of operating system , It has many basic functions , It is responsible for managing the process of the system 、 Memory 、 Device driver 、 File and network system , Determines the performance and stability of the system .

Linux The kernel consists of the following parts : memory management 、 Process management 、 file system 、 Device driver and network interface program .

3.2.1 System call interface (System Call Interface abbreviation SCI)

SCI Layer provides mechanisms to perform function calls from user space to the kernel . This interface depends on Architecture , Even in the same place The same is true of Li Qi family . SCI It's actually a very useful function call multiplexing and demultiplexing service .

stay ./linux/kernel You can find SCI The implementation of the , And in ./linux/arch Find architecture dependent parts of .

3.2.2 memory management

For any computer , Its memory and other resources are limited . In order to make the limited physical memory meet the application of memory A large demand for ,Linux It uses a method called “ Virtual memory ” Memory management mode of .Linux Divide memory into manageable “ Memory page ” ( For most architectures 4KB).Linux Includes ways to manage available memory , And physical and virtual mapping The hardware mechanism used . But memory management has more to manage 4KB buffer .Linux Provide for the right to 4KB Abstraction of buffer

for example slab distributor . This memory management mode uses 4KB Buffer as base , And then allocate the structure from it , And track memory page usage condition , For example, which memory pages are full , Which pages are not fully used , Which pages are empty . This allows the pattern to be dynamic according to the needs of the system Adjust memory usage .

To support multiple users using memory , Sometimes the available memory is consumed . For this reason , Pages can be moved out of memory And put it on the disk . This process is called exchange , Because pages will be swapped from memory to hard disk . The source code of memory management can be found in ./linux/mm Find .

3.2.3 Process management

A process is actually a running entity of a specific application . stay Linux In the system , Ability to run multiple processes at the same time ,Linux adopt Running these processes in turn over a short time interval “ multitasking ”. This short time interval is called “ Time slice ”, Let the process take turns The method of doing is called “ Process scheduling ” , The program that completes the schedule is called the scheduler .

Process scheduling control process pair CPU The interview of . When you need to select the next process to run , The scheduler selects the most worthwhile process to run .
A runnable process means that the process status of the process is TASK_RUNNING, This means that the process is runnable : Either it's running , Either in runqueue Waiting to run .
about 「 User space 」( Refers to the space in memory where user processes run ) For running processes , It can only be operational .
about 「 Kernel space 」( The space in memory where the kernel runs and provides services ) For running processes , Operational states are also possible .
One runqueue ( Run the queue ) yes scheduler ( Scheduler ) The basic data structure inside , It holds a list of runnable processes , The processes in these lists are then CPU perform .
scheduler ( Scheduler ) Also known as process scheduler ( Process scheduler ), It's part of the kernel , It assigns... To different runnable processes CPU Time ,Linux Using a simple priority based process scheduling algorithm to select a new process .

Through multi task mechanism , Each process can be considered to have its own exclusive computer , So as to simplify the programming .
Each process has its own address space , And can only be accessed by this process , In this way, the operating system avoids interference between processes and “ bad ” The program may cause Hazards of .
To accomplish a specific task , Sometimes it is necessary to integrate the functions of two programs , For example, a program output text , Another program sorts the text . So , The operating system also provides interprocess communication mechanisms to help accomplish such tasks .
Linux The common interprocess communication in The mechanism has a signal 、 The Conduit 、 Shared memory 、 Semaphores and sockets, etc .

The kernel passes through SCI Provides an application programming interface (API) To create a new process (fork、exec or Portable Operating System Interface [POSIX] function ), Stop the process (kill、exit), And communicate between them And synchronization (signal perhaps POSIX Mechanism ).

3.2.4 file system

and DOS Different operating systems ,Linux A separate file system in the operating system is not defined by a drive letter or drive name ( Such as A: or C: etc. ) To mark . contrary , and UNIX The operating system is the same ,Linux The operating system combines separate file systems into a single layer The secondary tree structure , And a separate entity represents the file system .s Linux Passing the new file system through a file system called “ Hang up ” or “ Hang up ” To mount it to a directory , So that different documents The system is integrated into a whole .Linux An important feature of the operating system is that it supports many different types of file systems . Linux The most commonly used file system in is Ext2, So is it Linux Native file system . but Linux Can also support FAT、VFAT、FAT32、MINIX And so on , It can exchange data with other operating systems conveniently . because Linux Supports many different file systems , And organize them into a unified virtual file system .

Virtualizing file systems :

Virtual file system (VFS) yes Linux A very useful aspect of the kernel , Because it provides a general interface for the file system like .VFS stay SCI And the file system supported by the kernel . namely VFS Provides a... Between the user and the file system Switch layer .

Virtualized file systems hide the details of various hardware , Separate file system operations from the specific implementation details of different file systems , by All devices provide a unified interface ,VFS Dozens of different file systems available . Virtual file systems can be divided into logical file systems And device drivers . Logical file system means Linux Supported file systems , Such as ext2,fat etc. , Device drivers refer to each type of hardware The device driver module written by the controller .

3.2.5 Device driver

The device driver is Linux Main parts of the kernel . Similar to the rest of the operating system , Device drivers run in a highly privileged processor environment , So that the hardware can be operated directly , But that's why , Any device driver error can lead to To crash the operating system .

Device drivers actually control the interaction between the operating system and hardware devices . Device drivers provide a set of abstract interfaces that the operating system can understand to complete the interaction with the operating system , The specific operation details related to hardware are completed by the device driver become .

generally speaking , Device driver is related to device control chip , for example , If the computer hard disk is SCSI Hard disk , You need to use SCSI The driver , instead of IDE drive Program .

3.2.6 Network interface program

Provides access to various network standards and support for various network hardware . Network interface can be divided into network protocol and network driver . The Internet The protocol part is responsible for implementing every possible network transmission protocol . as everyone knows ,TCP/IP Agreement is Internet Standard agreement for , meanwhile It's also a de facto industrial standard .Linux Network implementation support for BSD Socket , Support all of TCP/IP agreement .Linux The web of the kernel The collateral part is composed of BSD Socket 、 Network protocol layer and network device driver .

The network device driver is responsible for communicating with the hardware device , Every possible hardware device has its own device driver .

Linux Kernel video learning materials +qun720209036 obtain

more Linux Advanced server development includes C/C++,Linux,Nginx,ZeroMQ,MySQL,Redis,MongoDB,ZK, Streaming media ,P2P,K8S,Docker,TCP/IP, coroutines ,DPDK Multiple advanced knowledge points to share . Click the link C/C++Linux Server development / Back office architect - Learning video

本文为[Linux server development]所创,转载请带上原文链接,感谢

  1. 【计算机网络 12(1),尚学堂马士兵Java视频教程
  2. 【程序猿历程,史上最全的Java面试题集锦在这里
  3. 【程序猿历程(1),Javaweb视频教程百度云
  4. Notes on MySQL 45 lectures (1-7)
  5. [computer network 12 (1), Shang Xuetang Ma soldier java video tutorial
  6. The most complete collection of Java interview questions in history is here
  7. [process of program ape (1), JavaWeb video tutorial, baidu cloud
  8. Notes on MySQL 45 lectures (1-7)
  9. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  10. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  11. 精进 Spring Boot 03:Spring Boot 的配置文件和配置管理,以及用三种方式读取配置文件
  12. Refined spring boot 03: spring boot configuration files and configuration management, and reading configuration files in three ways
  13. 【递归,Java传智播客笔记
  14. [recursion, Java intelligence podcast notes
  15. [adhere to painting for 386 days] the beginning of spring of 24 solar terms
  16. K8S系列第八篇(Service、EndPoints以及高可用kubeadm部署)
  17. K8s Series Part 8 (service, endpoints and high availability kubeadm deployment)
  18. 【重识 HTML (3),350道Java面试真题分享
  19. 【重识 HTML (2),Java并发编程必会的多线程你竟然还不会
  20. 【重识 HTML (1),二本Java小菜鸟4面字节跳动被秒成渣渣
  21. [re recognize HTML (3) and share 350 real Java interview questions
  22. [re recognize HTML (2). Multithreading is a must for Java Concurrent Programming. How dare you not
  23. [re recognize HTML (1), two Java rookies' 4-sided bytes beat and become slag in seconds
  24. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  25. RPC 1: how to develop RPC framework from scratch
  26. 造轮子系列之RPC 1:如何从零开始开发RPC框架
  27. RPC 1: how to develop RPC framework from scratch
  28. 一次性捋清楚吧,对乱糟糟的,Spring事务扩展机制
  29. 一文彻底弄懂如何选择抽象类还是接口,连续四年百度Java岗必问面试题
  30. Redis常用命令
  31. 一双拖鞋引发的血案,狂神说Java系列笔记
  32. 一、mysql基础安装
  33. 一位程序员的独白:尽管我一生坎坷,Java框架面试基础
  34. Clear it all at once. For the messy, spring transaction extension mechanism
  35. A thorough understanding of how to choose abstract classes or interfaces, baidu Java post must ask interview questions for four consecutive years
  36. Redis common commands
  37. A pair of slippers triggered the murder, crazy God said java series notes
  38. 1、 MySQL basic installation
  39. Monologue of a programmer: despite my ups and downs in my life, Java framework is the foundation of interview
  40. 【大厂面试】三面三问Spring循环依赖,请一定要把这篇看完(建议收藏)
  41. 一线互联网企业中,springboot入门项目
  42. 一篇文带你入门SSM框架Spring开发,帮你快速拿Offer
  43. 【面试资料】Java全集、微服务、大数据、数据结构与算法、机器学习知识最全总结,283页pdf
  44. 【leetcode刷题】24.数组中重复的数字——Java版
  45. 【leetcode刷题】23.对称二叉树——Java版
  46. 【leetcode刷题】22.二叉树的中序遍历——Java版
  47. 【leetcode刷题】21.三数之和——Java版
  48. 【leetcode刷题】20.最长回文子串——Java版
  49. 【leetcode刷题】19.回文链表——Java版
  50. 【leetcode刷题】18.反转链表——Java版
  51. 【leetcode刷题】17.相交链表——Java&python版
  52. 【leetcode刷题】16.环形链表——Java版
  53. 【leetcode刷题】15.汉明距离——Java版
  54. 【leetcode刷题】14.找到所有数组中消失的数字——Java版
  55. 【leetcode刷题】13.比特位计数——Java版
  56. oracle控制用户权限命令
  57. 三年Java开发,继阿里,鲁班二期Java架构师
  58. Oracle必须要启动的服务
  59. 万字长文!深入剖析HashMap,Java基础笔试题大全带答案
  60. 一问Kafka就心慌?我却凭着这份,图灵学院vip课程百度云