<commit_before>#include <Kernel/Process.hh>
#include <Kernel/Thread.hh>
#include <Kernel/ProcessContext.hh>

using namespace Kernel;

namespace
{
   unsigned long nextId = 0;
};

std::list<Process*>&
getProcessList()
{
   static std::list<Process*> processList;

   return processList;
}

Process::Process()
   : idM(nextId++),
     contextM(new ProcessContext)
{
   printf("Process creation: %p\n", this);
   getProcessList().push_back(this);
}

Process::Process(uintptr_t pd)
   : contextM(new ProcessContext(pd))
{
   printf("Process creation: %p (existing pd: %p)\n", this, (void*)pd);
}

Process::~Process()
{
   printf("Process deletion: %p\n", this);
   
   for (auto& t : threadsM)
   {
      delete t;
   }
   
   delete contextM;<commit_msg>init id for all process, use atomics<commit_after>#include <Kernel/Process.hh>
#include <Kernel/Thread.hh>
#include <Kernel/ProcessContext.hh>

using namespace Kernel;

namespace
{
   volatile unsigned long nextId = 0;

   unsigned long getNextId()
   {
      return __sync_fetch_and_add(&nextId, 1);
   }
};

std::list<Process*>&
getProcessList()
{
   static std::list<Process*> processList;

   return processList;
}

Process::Process()
   : idM(getNextId()),
     contextM(new ProcessContext)
{
   printf("Process creation: %p\n", this);
   getProcessList().push_back(this);
}

Process::Process(uintptr_t pd)
   : idM(getNextId()),
     contextM(new ProcessContext(pd))
{
   printf("Process creation: %p (existing pd: %p)\n", this, (void*)pd);
}

Process::~Process()
{
   printf("Process deletion: %p\n", this);

   for (auto& t : threadsM)
   {
      delete t;
   }

   delete contextM;
{'fraction_non_alphanumeric': 0.15661182205971969, 'fraction_numerical': 0.0018281535648994515, 'mean_word_length': 4.13125, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3900759', 'n_tokens_mistral': 574, 'n_tokens_neox': 564, 'n_words': 123}