concurrency - Modeling synchronization using actors -


i'm trying understand how solve dining philosophers problem using actors. in case don't know, crux of problem thread needs obtain 2 locks before can proceed...and there multiple threads vying these 2 locks.

here's 1 way can model using actors:

# asynchronously request locks 2 forks (both forks actors) lock1 = fork1.future.lock lock2 = fork2.future.lock  if lock1 && lock2 # wait both locks   ... critical section end 

but think result in deadlock if 2 threads have 1 lock each , waiting other thread give lock.

in general, how model accessing 2 resources atomically using actors?

there implementation of solution problem written in scala using akka actors here.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -