Hello everybody, I enjoyed the Game Loops tutorial on this board, but I have a slightly different problem, so I decided to post.
I have 10 balls-Threads, and I need every one of them to move once, then wait for the others to move before it can
move again. Sounds awful, it is awful, but please bear with me. I’ll design it better next time.
If the 10 balls were not Threads, moving them one by one would be as simple as selecting then in a for loop.
Since I screwed it up, now it’s a synchronization nightmare, and I’d like the simplest of the solutions, if you have one, to make
those threads run the way I want.
The balls can move like this
turn 1) 1, 2, 3, 4, 5, …, 10
turn 2) 10, …, 5, 4, 3, 2, 1
turn 3) 2, 1, 3, 5, 4, …, 10
But not like this
turn 1) 2, 2, 1, 3, 3, 3, …, 10
BTW I tried searching round-robin on Google, and I found some simulations of a real scheduler, so let me make this clear
I do not need a quantized time (some thread can take more time than the others to execute)
I do not need absolute timing (maybe it can help, but if your solution is simpler without, then it’s better without)
EDIT: see this post for further informations (and a different example)