用 Erlang 写传统的并发问题容易吗?
我学习了操作系统课程,其中我们学习了常见的并发问题,例如:哲学家就餐问题、生产者-消费者问题、读者和消费者问题。 作者问题...
既然他们的主要目的是保护共享变量,那么尝试在 Erlang 中解决这些问题有意义吗? 或者也许我只是需要更多的 Erlang 培训来找出解决方案?
谢谢
I have followed an operative system course where we learned usual concurrency problems as: the dinning philosophers problem, producer-consumer problem, readers & writers problem...
Since their main purpose is to protect a shared variable, does it make sense to try to solve these problems in Erlang? Or maybe I just need more Erlang training to figure out the solution?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我理解这个问题,但这些问题与锁定和互斥有关。
Erlang 通过 Actor 做事的方式避免了锁定问题。 在 Erlang 中创建生产者、消费者、读取器和写入器是一件好事,但就解决互斥问题而言,您将使用消息而不是共享变量。
在 Erlang 中,你“不共享任何内容”。
I understand the question, but those problems have to do with locking and mutual exclusion.
Erlang's way of doing things through Actors avoids the locking problem. Creating producers and consumers and readers and writers are a good thing to do in Erlang, but as far as solving the mutual exclusion problem, you would be using messages instead of a shared variable.
In Erlang, you "share nothing".
这个链接可能对您有帮助
可以肯定的是,Erlang 的现实世界应用程序必须处理并发,线程争夺某些资源。
有一本优秀的书涵盖了所有这些主题以及更多内容,由 Erlang 的创建者 Joe Armstrong 撰写。
Erlang 编程:并发世界的软件
This link might help you
It is certain that real world applications of Erlang will have to deal with concurrency, with threads fighting over certain ressources.
There is an excellent book which covers all this subject and many more, written by Joe Armstrong, the creator of Erlang.
Programming Erlang : Software for a concurrent world