Your question has been migrated to Programmers, and I've edited the question to narrow the scope.
Part of the challenge with your original question was that it was overly broad. That breadth made it difficult to fit your question within a particular site.
One of the bigger aspects that I edited out of your question was the re-use and portability aspects. While it's nice to try and find a more general solution to a problem, sometimes the problem at hand is more than enough to tackle.
I also tried to summarize the two approaches you were considering, which boiled down to using two processes or a single process with multiple threads. In order to help keep the question from getting closed (again) as too-broad, I provided some suggested approaches within your question.
That said, I maintained your original constraints regarding time-to-completion and limited hardware resources.
One thing I wasn't able to add in but would help garner you better answers is if you specified what language you are using. I'm using it's C based upon your system calls to fork()
and pipe()
but I didn't want to add that in without confirmation.