Drive Research diary-linked list + backup linked list

Source: Internet
Author: User
Use of linked list:

1. Define a chain table header. The single-chain table is single_list_entry, and the double-chain table is list_entry. Then initialize the linked list header. To initialize the chain header of a single-chain table, set its next field to null. The double-chain table directly calls initializelisthead.

② Insert elements into the linked list:

For a single-chain table, you can use pushentrylist to insert insertheadlist or inserttaillist from the end of the chain table. These three functions have two parameters. The first parameter is the pointer to the linked list header, and the second parameter is the link field of the element to be inserted.

③ Delete elements from the linked list:

Similar to inserting elements, a single-chain table uses ptrylist, while a double-chain table uses removeentrylist, removeheadlist, and removetaillist. Their parameters are pointers to the linked list header.

④ To get the elements in the linked list, we use the containing_record macro.

 

 Backup linked list

If you need a fixed-size memory block, but you do not know its size and usage frequency in advance, you should use the lookaside lists for performance reasons, the backup list is available only in kernel mode.
The backup list is a group of memory blocks of the same size allocated in advance. Some of these blocks are in use, and some are not used. When there is a memory allocation request, the system will traverse this list to find the nearest unallocated block. If unallocated blocks are found, the allocation request is quickly satisfied. Otherwise, the system must allocate data from the paging or non-Paging memory pool. Based on the frequency of allocation in the list, the system automatically adjusts the number of unallocated blocks to meet the allocation request. The higher the allocation frequency, the more blocks will be stored in the backup list. If the backup list is not always used, the space size is automatically reduced.

Use the backup linked list:

① Retain non-Paging memory for a paged_lookaside_list or npaged_lookaside_list object.

These two types of objects are used to manage the backup linked list. They can only be stored in non-Paging memory, because the system needs to access it at the upgraded IRQL level. These two objects are very similar, but linked lists of the paging type use fast_mutex for synchronization, rather than linked lists of the paging type use spin locks.

② Call the corresponding initialization function to initialize the lookaside linked list.

③ Allocate storage from the lookaside linked list and use the allocatefrom () function.

④ After use, the applied bucket on lookaside will be returned to lookaside.

⑤ Call the delete function to delete the linked list.

Service Functions

Description

Exinitializenpagedlookasidelist
Exinitializepagedlookasidelist

Initialize lookaside linked list

Exallocatefromnpagedlookasidelist
Exallocatefrompagedlookasidelist

Allocate a fixed memory block

Exfreetonpagedlookasidelist
Exfreetopagedlookasidelist

Release a memory block back to the lookaside linked list

Exdeletenpagedlookasidelist
Exdeletepagedlookasidelist

Delete lookaside linked list

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.