News for hackers. Stuff that matters.
Re:Pony is an open-source, actor-model, high performance pro... by weddpros on Thursday January 14, 2016 @01:39PM (#10903378)
>> It's deadlock free. This one is easy, because Pony has no locks at all!

> This is nonsense. Deadlock happens when multiple processes/threads are waiting for each other. It is not caused by locks.

Actually deadlocks happen when 2+ resources are not locked in the same order by 2+ processes/threads... As far as I know, in Pony there's no way to send a blocking message to another actor, so there's no lock, so there's no deadlock.

Please correct me if I'm wrong

Re:Pony is an open-source, actor-model, high performance pro... by ggchappell on Thursday January 14, 2016 @01:52PM (#10903472)
I shall refer to a higher authority:

> A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.

That is from Modern Operating Systems, 4th ed. (2015), by A.S. Tanenbaum & H. Bos, page 439. (By "process" they really mean "process or thread".)

One way for thread A to wait on thread B is as you said: thread A can request a lock that thread B currently owns; then A waits for B. So requesting locks in opposite orders can result in deadlock. But of course if there are no locks, then no such waiting occurs, and so deadlock from this cause is impossible.

But there are other ways to wait. If var_a and var_b are shared variables, then code like the following might result in deadlock (The following code is in C; to simplify things, I'm assuming that data races and memory-access ordering are not issues.)

Thread A does:

    var_a = 1;
    while (var_b != 0) ;
    var_a = 0;
And thread B does:

    var_b = 1;
    while (var_a != 0) ;
    var_b = 0;
If Pony is capable of executing code like the above, then deadlock is possible.
Re:Pony is an open-source, actor-model, high performance pro... by 0cachecoherency on Thursday January 14, 2016 @02:43PM (#10903876)
Pony prevents you from writing that code. All communication between actors is by message passing, and there are no global variables. Check out reference capabilities.
Re:Pony is an open-source, actor-model, high performance pro... by m0th87 on Thursday January 14, 2016 @03:26PM (#10904186)
You can deadlock in purely message passing code, even if there are no blocking sends. See an example in Erlang: http://james-iry.blogspot.com/2009/04/erlang-style-actors-ar...
Re:Pony is an open-source, actor-model, high performance pro... by 0cachecoherency on Friday January 15, 2016 @04:22AM (#10908135)
That anti-pattern isn't possible in Pony, because Pony has no blocking receive call.
Re:Pony is an open-source, actor-model, high performance pro... by dozzie on Friday January 15, 2016 @06:07AM (#10908493)
Of course, and Pony prevents programmer from writing code that waits for anything else. Sure. We're supposed to believe this?
Re:Pony is an open-source, actor-model, high performance pro... by ggchappell on Thursday January 14, 2016 @02:49PM (#10903915)
Wow, so maybe the no-deadlock guarantee really does say something nontrivial. Thanks for the heads up.
Re:Pony is an open-source, actor-model, high performance pro... by betenoire on Thursday January 14, 2016 @02:02PM (#10903539)
There are many ways code can grind and thrash to a halt, like your code shows. But a deadlock refers specifically to the idea of two processes waiting until the other is done before they proceed. It's a scheduling problem, and a lock is used for synchronization. If there are no locks (spinlocks, semaphores, etc), there are no deadlocks by name (just other problems).
Re:Pony is an open-source, actor-model, high performance pro... by ggchappell on Thursday January 14, 2016 @02:12PM (#10903618)
> ... there are no deadlocks by name (just other problems).

Okay, supposing we have a definition of deadlock that agrees with your usage: sure. But then these "other problems" you mention will have exactly the same practical effect as deadlock, right? A program will hang, sometimes unpredictably, based on more or less random decisions made by some low-level scheduling algorithm.

And in that case, Pony's guarantee of no deadlock is (1) completely correct, and (2) completely meaningless, from the point of view of a programmer whose concern is that his code will behave as required.

Am I wrong? EDIT. Maybe: https://news.ycombinator.com/item?id=10903876