1) What kernel locks does Linux have?
Locks are required due to several kernel mechanisms. SMP multi-processor mechanism kernel preemption mechanism Interrupt Processing Mechanism schedule ()
Spinlock (lightweight lock with NS-level hold time)
The feature is that only one person can be entered in the critical section, and those who cannot obtain the lock are busy. Those who hold the lock cannot sleep. In kernel 4, only the schedule () mechanism cannot be protected by the spinlock.
Mutex lock (heavyweight lock, held in milliseconds)
The feature is that only one person can be entered in the critical section, and those who cannot obtain the lock will sleep until the lock is released. They can also sleep when holding the lock. In the four kernel mechanisms, only the interrupt processing mechanism can be protected by mutex.
2) What is the meaning of the user mode and Kernel Mode in Linux?
MS-DOS and other operating systems run in a single CPU mode, but some Unix-like operating systems use dual mode, can effectively achieve time sharing. On Linux machines, the CPU is either in trusted kernel mode
In the restricted user mode. Except that the kernel itself is in kernel mode, all user processes are running in user mode.
Kernel-mode code can access all processor instruction sets and all memory and I/O space without restriction. If a user-mode process needs this privilege, it must call the device driver or other kernel module through a system call.
Code to send a request. In addition, user-mode code can contain missing pages, while kernel-mode code cannot.
In kernels 2.4 and earlier, user-mode processes can be switched out of context and preemptible by other processes. The kernel mode code can always exclusively occupy the CPU unless the following two conditions occur:
(1) it voluntarily abandons the CPU;
(2) An interruption or exception occurs.
2.6 kernel preemption is introduced, and most kernel-mode code can also be preemptible.
3) How to Apply for a large kernel memory?
In the Linux kernel environment, the success rate of applying for a large block of memory decreases with the increase of the system running time. Although the vmalloc series can be called to apply for memory with a physically discontinuous but continuous virtual address, after all, it uses
Low Efficiency and limited memory address space for vmalloc on 32-bit systems. Therefore, it is generally recommended to apply for large memory segments during the system startup phase, but the probability of success is only relatively high, rather than 100%. If the program is true
If the application is successful or not, you can only use boot memory)
4) What are the main methods for inter-process communication?
(1) pipeline (PIPE): the pipeline can be used for communications between kinship processes, allowing one process to communicate with another process with which it has a common ancestor.
(2) Named Pipe (Named Pipe): The Named Pipe overcomes the restriction that the pipe has no name. Therefore, in addition to the functions of the pipe, it also allows communication between unrelated processes. Named Pipe in File System
Corresponding file name. The named pipe is created by running the mkfifo command or by calling the mkfifo command.
(3) signal: a signal is a complex communication method used to notify the receiving process of an event, except for inter-process communication, processes can also send signals to processes themselves.
In addition to Sigal, the early signal semantic function of UNIX also supports sigaction, which complies with posix.1 (in fact, this function is based on BSD, BSD in order to achieve reliable signal mechanism, it can also unify external interfaces and use
The sigaction function implements the signal function again ).
(4) Message Queue: A chain table of messages, including the POSIX Message Queue System V message queue. A process with sufficient permissions can add messages to the queue. A process with the read permission can
To read messages in the queue. Message Queue overcomes the limitations of insufficient signal carrying information, and pipelines can only bear unformatted byte streams and limited buffer size.
(5) shared memory: Enables multiple processes to access the same memory space, which is the fastest available IPC form. It is designed to reduce the running efficiency of other communication mechanisms. Often combined with other communication mechanisms, such as semaphores
To achieve synchronization and mutual exclusion between processes.
(6) semaphores (semaphore): used for synchronization between processes and between different threads of the same process.
(7) socket: a more general inter-process communication mechanism that can be used for inter-process communication between different machines. It was initially developed by the BSD branch of the UNIX system, but now it can be transplanted to other classes
On UNIX systems: both Linux and System V variants support sockets.
5) What are the functions used by the partner system to apply for kernel memory?
Zone-based buddy system is implemented in the physical Page Management ). Use a standalone buddy system to manage memory in different zones and monitor idle pages independently. Corresponding
Interface alloc_pages (gfp_mask, order), _ get_free_pages (gfp_mask, order), etc.
6) which of the following functions can I use to apply for kernel memory through the slab distributor?
7) How are Linux kernel and user spaces divided (taking a 32-bit system as an example )?
1 GB is the kernel space, and 3 GB is the user space (0 ~ 0xbfffffff user space) (0xc0000000 to 0xfffffff kernel space)
8) What are the characteristics of the memory applied for by vmalloc?
9) What is the scope of the memory space applied by the user program to use malloc?
0 ~ 0 xbfffffff
10) in a system that supports and enables MMU, does the Linux kernel and user program run in physical address mode or virtual address mode?
Virtual Address Mode
11) How many page tables does the ARM processor map buckets?
Two-level page table. A level-1 page table contains address translation entries in segments or pointers to level-2 page tables. The level-1 page table provides a large granularity for address ing. The level-2 page table contains large, small, and extremely small pages.
Address Change entries
12) What components does Linux use to support multiple file systems?
VFS
13) What are the key data structures of the Linux Virtual File System? (Write at least four)
Super_block inode file dentry
14) which data structure does the file or device operation function store?
File_operations
15) What files are included in Linux?
Common files: generally stream files
Directory file: Used to indicate and manage all files in the system
Connection file: used to share files in different directories
Device Files: including block device files and character device files. Block device files represent disk files and CDs. Character Device Files operate on terminals, keyboards, and other devices according to characters.
MPs Queue (FIFO) file: a method for communication between processes
Socket file: the file type is related to network communication.
16) What are the system calls for creating processes?
System exec family functions fork
17) How many methods can I call schedule () for process switching?
Direct call Delay
18) Does the Linux scheduler schedule a process based on its dynamic or static priority?
Dynamic Priority-completely fair scheduler CFS
19) What is the core data structure of process scheduling?
Task_struct
20) how to load and uninstall a module?
Insmod rmmod
21) in what space does the module and application run separately?
The module runs in the kernel space, and the application runs in the user space.
22) is the floating point Operation implemented by the application or the kernel in Linux?
Implemented by the kernel
23) CAN module programs use database functions that can be linked?
No
24) What content is cached in TLB?
25) which types of devices are available in Linux?
Character device fast device network device
26) What is the key data structure of the character device driver?
File_operations
27) What functions are included in the device driver?
Register prob release remove
28) How to uniquely identify a device?
Master and slave device numbers
29) How does Linux call the system?
SWI (soft Terminal)
30) What is the role of Linux Soft Interrupt and work queue?
Soft interruptions allow the user program to use the software resources provided by the system
Work queue is a mechanism in Linux kernel to push and execute jobs. This mechanism is different from BH or tasklets in that the working queue transfers the pushed work to a kernel thread for execution. Therefore, the advantage of working queue is that it allows rescheduling or even sleep.