在Erlang中编写传统的并发问题很容易吗? [英] Is it easy to write traditional concurrency problems in 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...
由于它们的主要目的是保护共享变量,在Erlang中尝试解决这些问题是否有意义?
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?
感谢
推荐答案
我理解这个问题,但是这些问题与锁定和互斥有关。
I understand the question, but those problems have to do with locking and mutual exclusion.
Erlang通过Actors做事情的方式避免了锁定问题。在Erlang中创建生产者和消费者以及读者和作者是一件好事,但就解决互斥问题而言,您将使用消息而不是共享变量。
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.
在Erlang,您无分享。
In Erlang, you "share nothing".
这篇关于在Erlang中编写传统的并发问题很容易吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!