Questions about flash concurrency

8 posts

Flag Post

Hi everybody,
I was thinking of using the shiny new flash concurrency for the purpose of having a dedicated worked thread for blitting.

It’s not like the worker thread actually unlocks any functionality that I couldn’t achieve by simply having the main loop do the game update and blitting alone, but by having a second thread the game will obviously run better on multicore CPUs.

However, I cannot find any information about how the flash worker threads are actually distributed across any potential CPU cores. I guess it’s up to the OS? But what I’m afraid of is that my dedicated blitting worker might end up on the same core as my main worker, removing the gains I would potentially get. Does anybody know if a thread can be “pushed” over to another core once it’s been established, if the OS finds that one core is overworked while another one hangs unused? Or is there any way to hint to the OS that these two threads should be on different cores?

 
Flag Post

Since it has the isSupported, I would assume that it leaves it up to the OS to place. If anyone has a single core that is single threaded(?) machine it would be cool if they could test to see if isSupported is false.

 
Flag Post

You can have more than one thread on a single core.

 
Flag Post

*Single threaded core? I’m not a hardware guy so please correct me.

EDIT Can’t some newer multi-threaded cores run multiple threads at the same time so it doesn’t matter if its just 1 core?

 
Flag Post

Indeed it can, in fact, a single core can even appear as more than one core, aka hyper-threading. My netbook has a dual core processor but in task manager I have 4 CPUs to assign my processes onto (I guess this sorta implies that a proccess can be moved from one core to another without being restarted?).

I wanna unlock more power for my application, not just multi-thread it for fun, as it runs just fine as a single thread. If both threads runs on the same core I’m not gaining anything at all, bar some overhead for making sure the two threads behave nicely to each other.

 
Flag Post

Pretty sure moving threads between cores mid-way through excecution will result in a context switch at both ends, thus costing time which may not make up for the performance advantage for that particular pair of quantums. It would however make sense to force-assign a program thread to a given processor thread before execution begins (let me know if there is such functionality available); however if this is not possible, then I really wouldn’t go to too much effort trying to micromanage your concurrency.

Also remember to take the necessary precautions to make your concurrent system safe in terms of thread management.

 
Flag Post

Hmm, even if the moving of threads mid-way is costy, it’s not something that would happen continuously, just a one time cost. But it would really be great to be able to tell the flash VM to create the second thread on another core, if available.

 
Flag Post

I expect process management is not for Flash but for the OS itself. A separate Flash Player is a thread or a process, controllable by OS. So this option is there and on by default, you just can’t see it in Flash. :)