简体   繁体   English

Fober等人的无锁FIFO队列:多个消费者和生产者?

[英]Fober et al Lock-Free FIFO Queue: multiple consumers and producers?

I was wondering if the fifo queue presented in Fober et al's paper http://nedko.arnaudov.name/soft/L17_Fober.pdf was a multiple consumer and produce fifo queue. 我想知道在Fober等人的论文http://nedko.arnaudov.name/soft/L17_Fober.pdf中提出的fifo队列是否是一个多用户并产生了fifo队列。 If not, which is the best documented multiple consumer and producer FIFO queue? 如果没有,哪个是最好记录的多个消费者和生产者FIFO队列?

Thanks 谢谢

I haven't read the paper but I am making a big assumption here: The paper uses the CAS (compare and swap) technique to achieve the concurrency. 我没有阅读论文,但我在这里做了一个很大的假设:本文使用CAS(比较和交换)技术来实现并发。

Lock free does not mean block free. 无锁并不意味着无块。 The use of CAS will stall other threads, but at least one thread will be moving 'forwards' at all times. 使用CAS将阻止其他线程,但至少有一个线程将始终“向前”移动。

Multiple producers all write to the same queue - that isn't a problem. 多个生产者都写入同一个队列 - 这不是问题。 The trickiness is the multiple consumers. 棘手的是多个消费者。 If every consumer must access the data then I would implement that by multiple queues and the data would fall through to the next queue after being processed in one. 如果每个消费者必须访问数据,那么我将通过多个队列实现该数据,并且数据在一个处理后将落入下一个队列。 If you mean multiple consumers via threads then that would work on the above method 如果你的意思是通过线程的多个消费者,那么这将适用于上述方法

yes. 是。 read section '3.1 Linearizability' the pop operation assumes that concurrent dequeue might happen. 阅读“3.1线性化”部分,pop操作假设可能发生并发出列。 This means that multiple threads will be able to consume the queue. 这意味着多个线程将能够使用队列。

I don't know the "Fober queue" but have already written lock-free FIFOs as ring buffers. 我不知道“Fober队列”,但已经将无锁FIFO写为环形缓冲区。 What is possible relatively easily is a "inter-lock free" queue which means that readers do not block writers and vice versa but multiple readers must be serialized and multple writers must be too. 相对容易的是“无互锁”队列,这意味着读者不会阻止写入者,反之亦然,但必须对多个读者进行序列化,并且多个作者必须也是如此。 So it is not exactly lock-free but still there is no locking/blocking between the readers and writers. 所以它不是完全无锁,但读者和作者之间仍然没有锁定/阻塞。

Maybe there are even better approaches that allow even less locking but maybe this will already help you. 也许有更好的方法可以减少锁定,但也许这对你有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM