Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When your main thread creates a new thread, depending on how many CPUs you've got and a bunch of other things, the library/OS can decide to switch to the new thread immediately and run that new thread until it blocks or terminates; then switch back to the main thread which creates another new thread that runs until it blocks or terminates, and so on. In this case you'd never have more than 2 threads actually running at the same time (the main thread, and one of the new threads).</p> <p>Of course the more CPUs you have the more likely it is that the main thread will keep running long enough to spawn all of the new threads. I'm guessing that this is what is happened - your PC simply has a lot more CPUs than the ARM system.</p> <p>The best way to prevent this would be to make the new threads lower priority than the main thread. That way, when the higher priority main thread creates a lower priority thread, the library/kernel should be smart enough not to stop running the higher priority thread.</p> <p>Sadly, the implementation of pthreads on Linux has a habit of ignoring normal pthreads thread priorities. The last time I looked into it, the only alternative was to use real time thread priorities instead, and this required root access and creates a security/permissions disaster. This is possibly due to limitations of the underlying scheduler in the kernel (e.g. a problem that the pthreads library can't work around).</p> <p>There is another alternative. If your main thread acquires a mutex before creating any new threads and released it after all new threads are created, and if the other threads attempt to acquire (and release) the same mutex before doing any real work; then you'd force it to have all 7 threads at the same time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload