Understanding. Linux. Network. internals Reading Notes-Chapter 1. Introduction

Source: Internet
Author: User
Chapter 1 describes some common programming modes and skills in network code;
1) memory cache-some common data structure kernels are allocated and released using Slab (for example, sk_buff)
2) cache and hash table-reduces the average search time by increasing the size of the hash table to reduce the probability of average conflicts (DOS enables hash table items to be concentrated on the same hash value through specific parameters), slow down)
3) reference count-when a good kernel programmer accesses a data structure, the reference count of the data is increased or decreased to prevent accidental release.
4) garbage collection-the memory occupied by the collection of useless or expired data structures; asynchronous (use timer for timed checks) synchronization (activate the collector when a threshold value is reached)
5) function pointers and vfts-you can use the object-oriented feature to assign different values to function pointers when initializing Objects Based on different objects or different objects.
6) Use Scalable Data blocks in the Data Structure
Struct xx {
Int;
Char * B [2];
Chiar C [0]; // when a scalable block does not need to be extended, a pointer pointing to the end of a structure does not occupy any space.
}
7) Conditional compilation # ifdef
8) Branch check compilation optimization:
Err = do_something ();
If (ERR) handle_err ();
If do_something () has few errors, modify the code;
Err = do_something ();
If (unlikely (ERR) handle_err;
9) mutex-spin locks, read/write spin locks (locks can be clearly divided into read-only and read/write classes), RCU (there are many read requests and few read/write requests route subsystem lookup is more than update)
10) the host's byte sequence is converted to the network's byte sequence (each time the kernel reads and writes a variable that exceeds one byte in the IP header, the network's byte sequence must be first converted to the host's byte sequence or vice versa)
11) timing with test-related bug tracking statistics (such as counting the number of cache hits and failures...) (two jiffies differences)
12) iputils, net-tools, iproute2, cscope
13) Dead Code patch maintenance problems

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.