Resource intensive multithreading killing other processes
<p>I have a very resource intensive code, that I made, so I can split the workload over multiple pthreads. While everything works, the computation is done faster, etc. What I'm guessing happens is that other processes on that processor core get so slow, that they crash after a few seconds of runtime.</p>

<p>I already managed to kill random processes like Chrome tabs, the Cinnamon DE or even the entire OS (Kernel?).</p>

<p>Code: (It's late, and I'm too tired to make a pseudo code, or even comments..)
-- But it's a brute force code, not so much for cracking, but for testing passwords and or CPU IPS.</p>

<p>Any ideas how to fix this, while still keeping as much performance as possible?</p>

<pre><code>static unsigned int   NTHREADS = std::thread::hardware_concurrency();
static int            THREAD_COMPLETE = -1;
static std::string    PASSWORD = "";
static std::string    CHARS;
static std::mutex     MUTEX;

void *find_seq(void *arg_0)
{
  unsigned int _arg_0 =   *((unsigned int *) arg_0);
  std::string *str_CURRENT =  new std::string(" ");

  while (true)
  {
    for (unsigned int loop_0 = _arg_0; loop_0 &lt; CHARS.length() - 1; loop_0 += NTHREADS)
    {
      str_CURRENT-&gt;back() = CHARS[loop_0];

      if (*str_CURRENT == PASSWORD)
      {
        THREAD_COMPLETE = _arg_0;
        return (void *) str_CURRENT;
      }
    }

    str_CURRENT-&gt;back() = CHARS.back();

    for (int loop_1 = (str_CURRENT-&gt;length() - 1); loop_1 &gt;= 0; loop_1--)
    {
      if (str_CURRENT-&gt;at(loop_1) == CHARS.back())
      {
        if (loop_1 == 0)
          str_CURRENT-&gt;assign(str_CURRENT-&gt;length() + 1, CHARS.front());
        else
        {
          str_CURRENT-&gt;at(loop_1) =     CHARS.front();
          str_CURRENT-&gt;at(loop_1 - 1) = CHARS[CHARS.find(str_CURRENT-&gt;at(loop_1 - 1)) + 1];
        }
      }
    }
  };
}
</code></pre>