使消费者/生产者问题有点先进
通过引入某些方案或使其更复杂,可以使消费者/生产者问题在同步方面有什么办法。 我之所以问这是因为在更简单的层面上,生产者/消费者的问题太容易了,我必须在该学期结束项目,因此,如果有人对我如何制定一个体面的中级/稍微高级级别有想法要实施的此问题的版本。
谢谢。
Is there any way for the Consumer/Producer problem in synchronization could be made more advanced by introducing some scenario or making it a little bit more complex.
The reason I am asking this is because at simpler level the Producer/Consumer problem is too easy and I have to make an end of semester project on it, so if any one have ideas regarding how can I make a decent intermediate/slightly advanced level version of this problem to implement.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在某些情况下将其扳平吗?如果消费者线程通过要放置脱水项目的本地指针的地址传递,则生产者线程可以直接加载结果。这意味着消费者一旦设置了任何静音,就不需要与任何互斥X一起运行 - 它已经加载了脱水项目。这意味着生产者线程可以识别将设置哪个线程运行,因此每个消费者都需要自己的事件/condvar/semaphore等待,并且该同步存储在队列中的容器中....或....您
..可以将同步引用存储在消费者arg指向的位置中,直到信号传导需要,当时释放该本地存储该脱水物品。这意味着在PC队列结构中只需要一个指针容器。
这种骗局是否有帮助,甚至可靠地工作?
是的:)
Spears it up in some cases? If consumer threads pass in the address of a local pointer where the dequeued item is to be placed, producer threads can directly load the result. That means that the consumer does not need to mess with any mutex once it is set running - it already has the dequeued item loaded. That implies that producer threads can identify which thread will be set running and so each consumer needs its own event/condvar/semaphore to wait on and that synchro stored in a container in the queue....or....
..you could store the synchro reference in the location pointed to by the consumer arg until it is required for signaling, at that time freeing up that local for storing the dequeued item. That means that only a pointer container is required in the PC queue struct.
Does this kind of chicanery help, or even work reliably?
Yes:)