Linked list management method based on reference counting

A reference counting and management method technology, applied in the field of reference counting-based linked list management, can solve problems such as access and invalid memory, and achieve the effect of improving the overall responsiveness

Pending Publication Date: 2020-09-29
CHANGSHA XINHONG SOFTWARE
View PDF0 Cites 1 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

Although in theory a separate management thread is used to modify the linked list structure, other threads can access and read the data in the linked list at the same time without the protection of any lock mechanism, but this will lead to another problem. It is absolutely safe to add nodes to the linked list, and the actual process of deleting nodes will eventually release the memory resources of the deleted nodes. If a thread is still accessing and reading the data of this node at this time, it will lead to invalid memory access

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Linked list management method based on reference counting
  • Linked list management method based on reference counting
  • Linked list management method based on reference counting

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0015] as attached figure 1 Shown: The linked list contains four nodes A, B, C, and D. The first access thread atomically adds 2 to the reference count before reading the linked list data. The reference count value is initially 1 and becomes 3 after adding 2. The management thread starts to delete node B, and the first access thread is accessing node A.

[0016] as attached figure 2 Shown: Node B is deleted from the linked list by the management thread, so that the link pointer of node A directly points to node C, but the link pointer of node B still points to node C. At this time, the first access thread is accessing node B, and the access thread can still continue to access node C through the link pointer of node B. After the management thread deletes the node B, it notifies the recovery thread to release the memory resources of the node B.

[0017] as attached image 3 Shown: before releasing the memory resources of node B, the recycling thread atomically decrements ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

A linked list management method based on reference counting comprises the steps of setting a reference counting value and a linked list protected by reference counting, nodes in the linked list at least comprise one link pointer, and the nodes are connected through the link pointer. The method further comprises the steps that a plurality of access threads read data from the linked list at the sametime, one management thread is responsible for adding or deleting nodes to the linked list, and one recovery thread releases memory resources of the deleted nodes. In the initial state, the referencecount value is 1 to represent the initial reference count of the management thread to the linked list; before reading the data in the linked list, the access thread firstly adds 2 to the reference count value in an atomization manner; if the quotation count value is not 0 before 2 is added, 2 is subtracted from the quotation count value in an atomization mode after the process of reading the linked list data is completed, and if the quotation count value is 0 before 2 is added, 1 is subtracted from the quotation count value in the atomization mode after the process of reading the linked listdata is completed.

Description

technical field [0001] The invention relates to the field of computer system software programming, in particular to a linked list management method based on reference counting. Background technique [0002] A linked list is a commonly used data structure in a computer system. Usually, there is no problem with multiple threads accessing and reading the data of each node of the linked list at the same time. There is no data exception of access conflict between multiple threads. When multiple threads add or delete nodes to the linked list at the same time, it is necessary to use the lock (Lock) mechanism to ensure the integrity of the linked list structure, that is, the linked list structure can only be modified after a thread successfully obtains the lock. Conventional locks will cause only one thread to access or modify the linked list at any time, and the efficiency will be greatly reduced. At present, the commonly used improvement scheme is to use the read-write lock (RWLo...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Applications(China)
IPC IPC(8): G06F16/901G06F9/50
CPCG06F9/5016G06F9/5022G06F16/9024
Inventor 龙恢管志坚
Owner CHANGSHA XINHONG SOFTWARE
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products