发明名称 Dual-buffer serialization and consumption of variable-length data records produced by multiple parallel threads
摘要 Under control of the consumer, it is determined that a first buffer is empty and that a second buffer contains data; a first compare-double-and-swap operation within a spin loop is executed to swap a double pointer of the first buffer and a double pointer of the second buffer, wherein responsive to the executing of the operation the consumer drains the second buffer, and wherein the executing of the operation directs the at least one producer to fill the first buffer; and it is determined that the first buffer and the second buffer are empty and the consumer waits for a notification from one of i) the at least one producer and ii) a timer. Under control of the at least one producer, a second compare-double-and-swap operation within a spin loop is executed to atomically locate the first buffer and update the double pointer of the first buffer.
申请公布号 US9268526(B2) 申请公布日期 2016.02.23
申请号 US201414490346 申请日期 2014.09.18
申请人 International Business Machines Corporation 发明人 Mints Vitali
分类号 G06F3/06;G06F5/12;G06F5/10 主分类号 G06F3/06
代理机构 Konrad, Raynes, Davda and Victor LLP 代理人 Davda Janaki K.;Konrad, Raynes, Davda and Victor LLP
主权项 1. A method, comprising: under control of a consumer: determining, with a processor of a computer, that a first buffer is empty and that a second buffer contains data, wherein the first buffer has a double-pointer, and wherein the second buffer has a double pointer;executing a first compare-double-and-swap operation within a spin loop, wherein the executing includes swapping the double pointer of the first buffer and the double pointer of the second buffer;draining the second buffer by: in response locating a next data record in the second buffer, processing the next data record; andin response to determining that there are no more data records to be processed in the second buffer and that multiple producers are suspended, resuming the multiple producers; and under control of at least one producer of the multiple producers, filling the first buffer by: in response to determining that there is enough room for a data record in the first buffer, executing a second compare-double-and-swap operation within a spin loop, wherein executing the second compare-double-and-swap operation includes atomically locating the first buffer and updating the double pointer of the first buffer to reserve a slot for a data record in the first buffer;in response to determining that there is not enough room for the data record and determining that the consumer is idle, notifying the consumer; andin response to determining that there is not enough room for the data record and determining that the consumer is not idle, suspending the multiple producers.
地址 Armonk NY US