Adaptive multi-threaded buffer
First Claim
1. A method comprising:
- receive a request from a writer process executing on a processor to write data to a buffer;
increment a writer index to a next slot in the buffer;
reserve a first write slot for the writer process; and
write data from the writer process to the first write slot;
receive a request from a reader process to read data from the buffer;
increment a reader index to reserve a read slot for the reader process;
read the content of the read slot and set the slot content to null in an atomic manner;
if the read slot content is null, then determine whether the buffer has been resized;
if the buffer has been resized, increment the reader index;
reserve a new read slot for the reader process; and
read the content of the new read slot and set the slot content to null in an atomic manner.
2 Assignments
0 Petitions
Accused Products
Abstract
An adaptive multi-thread buffer supports multiple writer process and reader processes simultaneously without blocking. Writer processes are assigned a reserved write slot using a writer index that is incremented for each write request. When a reserved write slot is not null, the buffer is resized to make room for new data. Reader processes are assigned a reserved read slot using a reader index that is incremented for each read request. When data is read out to the reader process, the read slot content is set to null. When a writer process attempts to write null data to a write slot, the buffer replaces the null write data with an empty value object so that content of the buffer is null only for empty slots. When an empty value object is read from a slot, the buffer replaces the content with null data to send to the reader process.
-
Citations
16 Claims
-
1. A method comprising:
-
receive a request from a writer process executing on a processor to write data to a buffer; increment a writer index to a next slot in the buffer; reserve a first write slot for the writer process; and write data from the writer process to the first write slot; receive a request from a reader process to read data from the buffer; increment a reader index to reserve a read slot for the reader process; read the content of the read slot and set the slot content to null in an atomic manner; if the read slot content is null, then determine whether the buffer has been resized; if the buffer has been resized, increment the reader index; reserve a new read slot for the reader process; and read the content of the new read slot and set the slot content to null in an atomic manner. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A method for resizing a buffer, comprising:
-
determine an original buffer is full when content of a slot that is reserved for a new writer process executing on a processor is not null; create a new buffer; move data from slots in the original buffer to slots in the new buffer; set a reader index to point to last slot in new buffer; set a writer index to point to last non-null element in new buffer; receive a request from the writer process to write data to the buffer; increment the writer index to a next slot in the buffer; reserve a first write slot for the writer process; and write data from the writer process to the first write slot. - View Dependent Claims (8, 9, 10, 11, 12, 13)
-
-
14. A computer-readable storage device not comprising a propagated signal or wave storing computer-executable instructions that when executed by at least one processor cause the at least one processor to perform a method for writing and reading data to a buffer, the method comprising:
-
receiving a request from a reader process to read data from the buffer; incrementing a reader index; reserving a read slot for the reader process; sending the content of the read slot to the reader process and set the slot content to null in an atomic manner; if the read slot content is null, then determining whether the buffer has been resized; if the buffer has been resized, incrementing the reader index; reserving a new read slot for the reader process; reading the content of the new read slot and set the slot content to null in an atomic manner; receiving a request from a writer process to write data to the buffer; incrementing a writer index to a next slot in the buffer; reserving a first write slot for the writer process; and writing data from the writer process to the first write slot. - View Dependent Claims (15, 16)
-
Specification