Notes on an in-depth understanding of Linux kernel
Source: Internet
Author: User
Notes on "deep understanding of Linux kernel"-general Linux technology-Linux programming and kernel information. The following is a detailed description. Author: Wheel
1. hard link and soft link)
Hard link: the file name contained in the directory is a hard link of the file, or a link for short. There are two restrictions on hard links: users are not allowed to create hard links for directories, because this may turn directories into a ring tree. Hard links can be created only between files in the same file system.
Soft link: to overcome these restrictions, a soft link is introduced and becomes a symbolic link ). A symbolic link file can point to any file or directory on any file system, or even to a non-existent file.
2. file descriptors, index nodes, and open file objects
The information required by the file system to process files is contained in a data structure named inode. Each file has its own index node, which is used by the file system to identify files.
The file descriptor represents the interaction between processes and open files, and the open file object contains the interaction-related data. In fact, the process creates an object for each opened file, and the file descriptor is the index of the object. Several processes can open the same file. The file system assigns each process a separate file object and file descriptor.
3. mmap () system call
This system call allows a part of the files or information stored on the block device to be mapped to a part of the address space of the process. Memory ing provides another option for normal read/write data transmission methods. If a file is shared by several processes, each process address space shared by the file contains its memory ing.
4. Synchronization and mutex
Semaphores (semaphore) are valid for both single-processor and multi-processor. Each semaphore can be considered as an object, which is composed of the following:
An integer variable;
A linked list of waiting Processes
Two source methods: down () and up ()
In Linux, semaphores are requested in the specified order to avoid deadlocks.
Spin lock is invalid in a single-processor environment.
5. Signal)
Unix signals provide a mechanism for reporting system events to processes. Each event has its own signal number, which is usually represented by a symbolic constant, such as SIGTERM. There are two system events:
Asynchronous notification: for example, when a user presses the interrupt key (usually Ctrl + C), it sends an interrupt signal SIGINT to the foreground process.
Synchronization error or exception: for example, when a process accesses an invalid memory address, the kernel sends a SIGSEGV signal to the process.
Generally, processes can process the received signals in the following two ways:
Ignore the signal, or asynchronously execute a specified process (Signal Processing Program ). If the process does not specify any method, the kernel will take the default processing operation based on the signal number.
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