Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Lock-free message queue implementation method

A technology of message queue and implementation method, applied in the field of lock-free message queue implementation, can solve problems such as performance loss, achieve the effects of improving performance, reducing the danger of program deadlock, and simplifying code debugging work

Inactive Publication Date: 2013-06-19
OPZOON TECH
View PDF9 Cites 12 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0004] The technical problem solved by the present invention is how to solve the performance loss caused by invalid operations on locks and semaphores in the producer / consumer model

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
  • Lock-free message queue implementation method

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0017] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention.

[0018] The invention provides a lock-free message queue implementation method, such as figure 1 As shown, use the producer dispatching message mode to change the original consumer obtaining message mode. The methods include:

[0019] S1: The main thread obtains the message, and saves the message in the message queue;

[0020] The main thread is the producer, and the message is sent externally.

[0021] S2: The main thread detects whether all worker threads have idle worker threads; if not, continue to detect all worker threads until an idle worker thread is detected, then jump to step S3; if yes, then jump to step S3;

[0022] The worker thread is the consumer.

[0023] S3: the main thread sends the message to an idle worker thread, the idle worker thread receives the mess...

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 provides a lock-free message queue implementation method. The method includes a first step of utilizing a main thread to obtain messages and storing the messages in a message queue, a second step of utilizing the main thread to detect whether an idle worker thread exists in all worker threads, if the idle worker thread does not exist, continuing detecting all the worker threads until the idle worker thread is detected, and if the idle worker thread exists, skipping to a third step, the third step of utilizing the main thread to transmit the messages to the idle worker thread, wherein the idle worker thread receives and processes the messages, and the idle worker thread is changed to the worker thread, and a fourth step of transmitting an idle signal to the main thread after the worker threads complete processing of the messages. The lock-free message queue implementation method improves performance, decreases dangers of program deadlock, and simplifies code debugging operations on the condition that locking is avoided.

Description

technical field [0001] The invention relates to cloud computing technology, in particular to a lock-free message queue implementation method. Background technique [0002] In the thread / process model, the producer / consumer model is generally used to implement communication between threads / processes. This model uses semaphores to grab messages, and locks to ensure that each thread / process has safe access to the global message queue. However, the producer / consumer model frequently uses locks, resulting in poor performance. Contents of the invention [0003] (1) Solved technical problems [0004] The technical problem solved by the invention is how to solve the performance loss caused by invalid operations on locks and semaphores in the producer / consumer model. [0005] (2) Technical solution [0006] The present invention provides a method for implementing a lock-free message queue, the method comprising: [0007] S1: The main thread obtains the message, and saves the m...

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
IPC IPC(8): G06F9/46
Inventor 薛国良
Owner OPZOON TECH
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products