I’m writing a dynamically scheduled parallel algorithm, which spawns new processes when other processes run out of work. I’m keeping a counter of currently running processes so I don’t spawn more than max available processes. I would like to keep this counter atomic (to prevent data races).
My thought process so far:
- Process 0 spawns 4 new processes (P1, P2, P3, P4)
- P0 holds a counter which P1-4 update
- P1-4 send their updates through a remote channel, and P0 updates the counter
- P1-4 want to access the counter, but they can’t just call
remotecall_fetchsince it might change in the meantime
How do I achieve atomicity of this global counter using Julia processes?