Unlock instant, AI-driven research and patent intelligence for your innovation.

Queue access method and device

An access method and queue technology, applied in the field of queue access methods and devices, can solve problems such as low efficiency, long thread waiting time, and long time consumption, and achieve the effect of improving efficiency

Active Publication Date: 2017-07-21
TENCENT TECH (SHENZHEN) CO LTD
View PDF4 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

The process of context switching requires more resources and takes a long time
In addition, if the thread occupying the queue is not unlocked in time, it may cause other threads that need to access the queue to wait for a long time. Therefore, when the queue is accessed by locking, the efficiency is not high

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
  • Queue access method and device
  • Queue access method and device
  • Queue access method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0043] When accessing the queue, if multiple threads are used to access the queue by using the locking method, one thread accesses the queue and locks the queue, and if another thread needs to access the queue, since the queue has been locked, At this time, the thread will change from the running state to the waiting state and perform context switching. However, the process of context switching needs to occupy more resources and takes a long time. In addition, if the thread occupying the queue is not unlocked in time, other threads that need to access the queue may wait for a long time. Therefore, the efficiency of queue access by locking is not high.

[0044] In order to improve queue access efficiency, the embodiment of the present invention provides a queue access method, which can be applied to terminals, such terminals include but not limited to mobile phones, computers, tablet computers, etc. limited. see figure 1, the method flow provided by this embodiment includes:...

Embodiment 2

[0067] An embodiment of the present invention provides a method for accessing a queue. Combining the content of the first embodiment above, this embodiment takes the queue access as an operation of enqueueing as an example to illustrate the method provided by this embodiment. see figure 2 , the method flow provided by this embodiment includes:

[0068] 201: Create a second node to be added to the queue, where the second node includes a pointer variable whose value is null;

[0069] The queue contains at least one first node and queue tail pointer variable. The value of the queue tail pointer variable is used to point to the tail node of the queue. The tail node is the first node. Each first node contained in the queue contains at least one pointer variable. The value of the pointer variable is used to point to the next node connected to the current node, and the value of the pointer variable contained in the tail node is empty.

[0070] This embodiment does not specifically...

Embodiment 3

[0087] An embodiment of the present invention provides a method for accessing a queue. Combining with the content of the first embodiment above, the method provided in this embodiment is described with an example. see Figure 4 , the method flow provided by this embodiment includes:

[0088] 401: Obtain the value of the queue head pointer variable;

[0089] The queue contains at least one first node and queue tail pointer variable. The value of the queue tail pointer variable is used to point to the tail node of the queue. The tail node is the first node. Each first node contained in the queue contains at least one pointer variable. The value of the pointer variable is used to point to the next node connected to the current node, and the value of the pointer variable contained in the tail node is empty. In addition, a pseudo-node is included outside the queue, and the pseudo-node includes a pointer variable. The queue also includes a queue head pointer variable, and the valu...

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

The invention discloses a queue access method and device, belonging to the technical field of data access. Including: creating the second node to be added to the queue; obtaining the value of the pointer variable at the end of the queue, and judging whether the value of the pointer variable contained in the first node pointed to by the obtained value is empty; if the obtained value points to the first node If the value of the pointer variable contained in a node is not empty, it is determined that the value of the tail pointer variable is updated, and the updated value of the tail pointer variable is obtained until the first node pointed to by the updated value of the tail pointer variable is determined The value of the pointer variable contained in is empty, the second node is added to the queue, and the value of the pointer variable contained in the first node pointed to by the acquired value points to the second node. In the present invention, after the value of the tail pointer variable is updated due to parallel access, the queue entry operation of the node can still be continued, thereby realizing parallel access to the queue without locking the queue, thereby improving the efficiency of accessing the queue.

Description

technical field [0001] The invention relates to the technical field of data access, in particular to a queue access method and device. Background technique [0002] In the process of data access technology, the queue, as a data structure, is used in many occasions due to its FIFO (First Input First Output, first-in-first-out) characteristics, such as the design of algorithms. Among them, when accessing the queue, in order to improve resource utilization and program running speed, the program is logically divided into several threads in most cases, and the multi-thread concurrency mechanism is adopted to access the queue through multiple threads. [0003] A queue access method is provided in the related art. In this method, when thread A needs to access the queue, the queue will be locked first, and the thread A will not release the lock until the end of accessing the queue. According to the above access method, in the process of thread A accessing the queue, if a new thread...

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 Patents(China)
IPC IPC(8): G06F9/46
Inventor 贺辉超
Owner TENCENT TECH (SHENZHEN) CO LTD