0
votes

this is a follow up to this. (You don't have to read all the answers, just the question)

People explained to me the difference between processes and threads. On the one hand, I wanted processes so I could fully exploit all core of the CPU, on the other hand, passing information between processes was less than ideal, and I didn't want to have two copies of the huge object I was dealing with.

So I've been thinking about a way to do this, combining processes and threads; tell me if this makes sense. The main process in my program is the GUI process. I will have it spawn a "rendering-manager" thread. The rendering-manager thread will be responsible for rendering the simulation, however, it will not render them by itself, but spawn other processes to do the work for it.

These are the goals:

  1. Rendering should take advantage of all the cores available.
  2. The GUI should never become sluggish.

The reason I want the rendering-manager to be a thread is because it has to share a lot of information with the GUI: Namely, the simulation-timeline.

So do you think this is a good design? Do you have any suggestions for improvement?

Update:

Sorry for my confusing use of the word "render". By render I mean calculate the simulation, not render it on screen.

2
What's actually different about this question? It's your previous question all over again. - S.Lott
Here I proposed a certain design combining threads and processes and I want to know if it's good. I have read all the answers on the previous question several times. - Ram Rachum
@cool-RR: Please update your question with additional information. Perhaps clarify or emphasize parts of your question so it's clear that this is somehow different. - S.Lott
Okay, I updated it, is it good enough? - Ram Rachum

2 Answers

2
votes

Before using processes, make sure that:

  • Your algorithm can be parallelized between all the processors.
  • You need this parallelism.

In my opinion a good rule of thumb is:

  1. Make it work.
  2. Make it right.
  3. Make it fast.

So I'd suggest to “simply” use threads first. Maybe you will realize that even with one thread computing the simulation it's fast enough.

0
votes

The main process in my program is the GUI process. I will have it spawn a "rendering-manager" thread. The rendering-manager thread will be responsible for rendering the simulation, however, it will not render them by itself, but spawn other processes to do the work for it.

I'm no expert on graphics technologies, but this sounds a lot like what GPUs are intended for. Perhaps pygame is more what you're looking for?