Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, after a lot of wrangling to actually get the question out of you, here's the version I'm going to try to answer:</p> <blockquote> <p>After creating threads it's not guaranteed that any two threads will run simultaneously on a dual core processor. So if two threads don't run simultaneously I want priority be given such that thread 1(created first) will run first and thread 2(created second) will always run after thread 1. </p> </blockquote> <p>And luckily, the answer to <em>that</em> is fairly simple. Your program doesn't know which threads are run when. The OS doesn't tell you when it starts and stops a thread, so you can't code any kind of "is thread 1 running? If not, I'll pause and let that run" check.</p> <p>But you can set the threads to have different priorities. That indicates to the OS which ones it should schedule for execution. Give your threads a gradually decreasing priority (so thread 1 has a high priority, thread 2 one step lower and so on), and you'll have made something that kind of approximates what you want. On Windows, this might actually work out fairly well, since Windows always tries to pick the highest prioritized threads/processes available. Linux will try to ensure that all threads get <em>some</em> execution time, but will simply give <em>more</em> to higher prioritized ones.</p> <p>And of course, messing with priorities like this also affects how your program is scheduled in relation to everything else running on the PC. You're really trying to go about this the wrong way, and the saner solution would be to simply find another scheme for parallelizing this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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