c++ - How to paralleize search for a string in a file with a help of fork? (GNU Linux/g++) -


i got text file couple of lines , looking string in file. need pass following command line parameters program:
- file path
- string looking for
- maximum number of processes program allowed "fork" in order complete task.

how such program should constructed?

a couple of thoughts.

  • you have open file separately each process, otherwise share single file descriptor , have shared position in file (or not, see comments, may system specific...).
  • you may not see speed increase hoping due disk access and/or cache miss patterns.

you might able beat both issues memory mapping file (well still risk increased cache miss rate)...


how badly need this? runs real risk of being premature optimization. recommend against touching problem without compelling need. really.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -