ComputationalRadiationPhysics / redGrapes

Resource-based, Declarative task-Graphs for Parallel, Event-driven Scheduling :grapes:
https://redgrapes.rtfd.io
Mozilla Public License 2.0
20 stars 5 forks source link

Example for dining philosophers problem? #3

Closed sbastrakov closed 4 years ago

sbastrakov commented 6 years ago

This is not really an issue, but more of an idea to discuss. Is it worth making an example that implements the dining phisolophers problem ?

I think that could be done rather easily with resource hierarchy approach: create n resources (forks), n resource users (philosophers) are indexed, so essentially the same function is called n times.

ax3l commented 6 years ago

I like the idea, it's a nice demonstration.

sbastrakov commented 6 years ago

Then, unless @michaelsippel has objections, I could do it.

michaelsippel commented 6 years ago

Just a little thought: The dining philosophers problem is used to demonstrate concurrency, but the point about our Resource-Manager is sequential programs getting compressed for parallel execution. So the difference is: The concurrent tasks try to acquire and release resources, whereas the sequential tasks only start, if everything is ready.

But you could create a thread per philosopher, which pushes the tasks (think, eat) to one global queue.