Thu Mar 15 14:27:59 CET 2007
Christian S wrote:
>> Well, it depends on. Sometimes semaphores can be a simple a good
>> solution if they are used with care. But of course message passing is
>> more advanced and general than semaphores.
> I find message passing less advanced, I make fewer mistakes when using
>> Sorry, I explained bad in my previous email. Semaphores can be used
>> *not* only for sharing data but for other tasks, mainly synchronization.
>> In my sample file you can find a sample for barrier synchronization
>> using semaphores.
> Do you have any examples of tasks that you solve using your semaphores?
Sure. Please take a look at my previous post. The semaphore source file
is attached. There is also a file which is "semaphore_test.erl". In this
file you can find an example about how to use this semaphore module.
Also in that file "Barrier Synchronization" problem has been solved
using semaphores. "Barrier Synchronization" is used to synchronize some
processes where they do not have same speed to reach a point. So faster
processes who reach a point (when they are done with a task) should wait
for slower processes and when slowest process is done, all will begin
from that point again. There are many classic examples like "Dining
Philosophers", "Producers and Consumers" etc. which have been solved by
semaphores. But, please pay attention that I don't want to defend
semaphores against other modern techniques like message passing and so
on. There is no doubt that modern techniques are more practical and
efficient, but I thought that there might be programmers and tasks that
could be done even partly using semaphores, thats all.
More information about the erlang-questions