title: OpenMP shared data
body: <p>I'm somewhat new to OpenMP but have experience with parallel processing in general. I worked with <code>boost::threads</code> before and now I'm testing around with openmp.</p>
  
  <p>The problem is that I don't know how to handle shared data access because I don't really know what openmp does internally with shared data objects inside parallel loops.</p>
  
  <p>What I'm doing right now (this is working so far): I read files from disk into memory with mmap. I receive a pointer on char after the memory map part.</p>
  
  <p>OpenMP can now use this pointer inside an OpenMP parallel for loop and share the data between threads. I'm now able to search for regular expression matches inside the mapped and shared file with multiple threads checking every string against a (pretty long) list of regular expressions.</p>
  
  <p>I made this list (a vector containing regex) private inside the openmp loop, so every thread has it's own copy of this list.</p>
  
  <p>Here comes the problem:</p>
  
  <p>To dramatically increase performance of my application I need to be able to remove (regex-)items from this vector once they match a string.</p>
  
  <p>Now all the other active threads need to have this item removed from their list too asap.</p>
  
  <p>So I made this list a shared data object inside the openmp loop but now I get segmentation faults at runtime when I try to write (vector.erase(item#)) to the list.</p>
  
  <p>With boost::threads I would just have used a mutex for locking this object while writing/reading it.</p>
  
  <p>But openmp seems to handle most of the synchronization itself so now I wonder what would be the correct approach to handle this problem when using openmp which is new to me.</p>