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?
Comments
Post a Comment