SIMULTANEOUS SUBMISSION TO A MULTI-PRODUCER QUEUE BY MULTIPLE THREADS
First Claim
1. A method of submitting data to a shared queue by multiple producer threads, the method comprising:
- allocating a portion of memory in the shared queue for storing first thread output data to be written by a first producer thread of the multiple producer threads by advancing an outer pointer that indicates a next entry in the shared queue that is available for allocation, wherein the order in which the multiple producer threads store thread output data in the shared queue is different than the order in which contiguous portions of memory in the shared queue are allocated to the multiple producer threads;
writing, by the first producer thread, the first thread output data to the portion of memory;
determining, by the first producer thread, if the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written; and
advancing an inner pointer that indicates a last contiguous entry in the shared queue that has been submitted to the shared queue when the first producer thread determines that the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written.
1 Assignment
0 Petitions
Accused Products
Abstract
One embodiment of the present invention sets forth a technique for ensuring that multiple producer threads may simultaneously write entries in a shared queue and one or more consumers may read valid data from the shared queue. Additionally, writing of the shared queue by the multiple producer threads may occur in parallel and the one or more consumer threads may read the shared queue while the producer threads write the shared queue. A “wait-free” mechanism allows any producer thread that writes a shared queue to advance an inner pointer that is used by a consumer thread to read valid data from the shared queue.
38 Citations
20 Claims
-
1. A method of submitting data to a shared queue by multiple producer threads, the method comprising:
-
allocating a portion of memory in the shared queue for storing first thread output data to be written by a first producer thread of the multiple producer threads by advancing an outer pointer that indicates a next entry in the shared queue that is available for allocation, wherein the order in which the multiple producer threads store thread output data in the shared queue is different than the order in which contiguous portions of memory in the shared queue are allocated to the multiple producer threads; writing, by the first producer thread, the first thread output data to the portion of memory; determining, by the first producer thread, if the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written; and advancing an inner pointer that indicates a last contiguous entry in the shared queue that has been submitted to the shared queue when the first producer thread determines that the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A system for submitting data to a shared queue by multiple producer threads, the system comprising:
-
a memory that is configured to store a shared queue for access by a multi-threaded processor; and the multi-threaded processor that is configured to; allocate a portion of memory in the shared queue for storing first thread output data to be written by a first producer thread of the multiple producer threads by advancing an outer pointer that indicates a next entry in the shared queue that is available for allocation, wherein the order in which the multiple producer threads store thread output data in the shared queue is different than the order in which contiguous portions of memory in the shared queue are allocated to the multiple producer threads; write, by the first producer thread, the first thread output data to the portion of memory; determine, by the first producer thread, if the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written; and advance an inner pointer that indicates a last contiguous entry in the shared queue that has been submitted to the shared queue when the first producer thread determines that the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written.
-
-
12. A non-transitory computer-readable storage medium storing instructions that, when executed by a processor, cause the processor to execute multiple producer threads that submit data to a shared queue, by performing the steps of:
-
allocating a portion of memory in the shared queue for storing first thread output data to be written by a first producer thread of the multiple producer threads by advancing an outer pointer that indicates a next entry in the shared queue that is available for allocation, wherein the order in which the multiple producer threads store thread output data in the shared queue is different than the order in which contiguous portions of memory in the shared queue are allocated to the multiple producer threads; writing, by the first producer thread, the first thread output data to the portion of memory; determining, by the first producer thread, if the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written; and advancing an inner pointer that indicates a last contiguous entry in the shared queue that has been submitted to the shared queue when the first producer thread determines that the portion of the shared queue that was written was the only portion of memory in the shared queue that was allocated and had not been written. - View Dependent Claims (13, 14, 15, 16, 17, 18, 19, 20)
-
Specification