Basic concepts of the Linux kernel

Source: Internet
Author: User

Linux kernel learning, recommended books:

"Linux device Driver Development detailed second Edition", "Linux kernel design and implementation of the third edition", "Embedded Linux application Development complete manual"

First: To explain the basic knowledge of the Linux kernel, there is an overall framework, the follow-up will be gradually explained, step by step in depth.

1. Physical Address and virtual address

Address translation: The address used by the kernel must be a virtual address, but the CPU is really the last to use or access the physical address, so there must be a conversion process. The kernel's virtual address and physical address are just a difference between the 0xc0000000, so it's easy to get a virtual address from a physical address or a physical address from a virtual address.

Page table: In general, the size of the page is 4K, so the size of the page table is all the physical addresses you need to access divided by 4K. The smallest unit that Linux can find is the page.

Example: If the space you want to access is 4G, then the size of the page table is 1M. (4g= (4*1024m)/(4*1024) =1m)

The page table exists in memory. Linux is the conversion of virtual addresses to physical addresses by checking a page table in memory.

Properties of Memory: readable writable executable. Each page has properties.

Memory management in the 2.Linux kernel: the page (4K byte) allocates memory for the unit.

3. System invocation (Linux-specific): the media in which the user uses kernel functions (APIs).

Implementation: Through a exception, the application falls into the kernel to execute.

4. Kernel thread-The body of the program run.

Kernel only thread, no process: the kernel because the code space only one, kernel space is only one, all kernel threads share a kernel code, a common kernel space, all only threads, no process.

3 Scheduling modes: SCHED_RR time slice rotation SCHEDPRI priority SCHED_RT Real-time process (highest priority)

Timing: When a clock interrupt occurs, Linux performs a signal when the kernel state and the user state switch to each other.

5. Synchronization and inter-thread communication in the kernel

Atomic manipulation: The so-called atomic operation, which is never interrupted by any other task or event before execution is complete, says that its smallest execution unit cannot have a smaller execution unit, so the atom here actually uses the concept of matter particles in physics.

Synchronous communication mode: Spin lock Spin_lock and signal volume semaphore

Asynchronous communication mode: Signal signal

6. Interrupts

Interrupted hardware concept: is an external level signal.

Top half of interrupt Processing: A program segment that requires the Linux kernel to temporarily turn off other interrupt signals to process. Must be a program segment that handles critical and can be quickly completed at the same time. This program section must not wait for other conditions to occur.

The bottom half of interrupt processing: A lengthy program segment that is too late to be processed in the upper half, which is a program segment that waits for the results of other programs to run or to wait for additional resources.

7. Clock and timer management

The hardware concept of the clock: the clock is a hardware-based circuit that produces a timed interrupt.

RTC and System timer:rtc-real-time clocks or real-time counters. Resources that are part of the CPU perimeter.

Clocks are designed to be used for timing the system. And RTC is the system used to get the current system time, delay.

The system timer is an extension of the RTC, and in many cases it is used as a delay and as a calculation of relative time.

Tick and Jiffies:

Tick is the period of clock interruption. Suppose the system clock is 100M. Then the approximate tick value is 10ms.

Jiffies It is a global variable, and if the system is a 64-bit system, he is a 64-bit variable. Records the number of ticks that have been experienced since the power-up began.

8 File System Overview

Virtual file System (VFS): a middle tier that is generated by the Linux kernel in order to block the differences of the specific physical file system.

The main physical file system (EXT4,YAFFS2, etc.): EXT4 is the most important feature is the perfect log system. YAFFS2 is a more suitable file system to be deployed on NAND flash.

Ubifs (ARM real-time, fast execution rate) and btfs (prevent fragmentation) are two of the more popular new file systems.

Basic concepts of the Linux kernel

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.