ajaySekhri
ajaySekhri

Reputation: 15

Ways to process data which is coming at double speed than my processing speed

I was asked this question my someone and bit confused on same.

Q: how will you process the data which is coming at double speed than my processing speed?

I think of following:

  1. using queue to handle this. But if I use simply queue then size of queue required will be indefinetly large and i will still lag behind. As every t time i will have half more data that I can process. and I will keep laging exponentially.
  2. I use one thread for reading data and two more for processing. But suppose my data has to be processed serially then what happens.

Am still confused and any help on similar problems will be welcomed. I know there might be a standard solution for this but am unaware of same.

I would like to implement in c/c++

Upvotes: 0

Views: 86

Answers (1)

PA.
PA.

Reputation: 29339

Short answer: you'll need some kind of parallel processing. It's not easy.

Long answer: Depending on your workload requirements, and whether the bottleneck is in IO or in CPU, it might simply be multithreading on a single core, or on a multicore processor, or on a shared memory multiprocessor or even distributed between multiple nodes. It can be just a matter of distributing and balancing your work between the worker units, if the problem is simple enough (embarrasingly parallel) or you'll need to explicitly do some parallel programming. There are fundamentally two parallel programming models: OpenMP, for multithreading in multicore systems with shared memory (either symmetric or non-uniform access); and MPI, for distributed processing in a low-latency high-bandwidth network. To complicate even further, OpenMP and MPI might perfectly run together, in a hybrid parallel programming runtime environment: OpenMP distributes and coordinates the parallel compute load between the cores on each node, and MPI does it between the nodes. Be aware, it is very tough work.

Upvotes: 1

Related Questions