Questions regarding running two functions simultaneously


I am working on a project for RF signal data receiving and sampled data processing.

Right now, I have two separate functions, one function can continuously receive sampled RF signal data; and another function can continuously process the received signal data. For now, in my testing, I run the signal receiving function first, and stored the signal data in a file; then the processing function can read data from that file and process it. So it is a post-processing work flow.

Before, my signal processing function was kinda slow. For processing the received one second’s data, the time consumption was a couple of seconds. Now, after optimization, the processing function can work very fast, it takes much less than one second for processing one second’s data. Therefore, I am pretty sure that the processing function can work with the signal receiving function together in the same time. So it can be a real time processing.

But, I am now wondering what is the best way to make the two functions run simultaneously? Should it belong to multi-thread programming? I didnt have any experience with this kind of question. So can anyone give me any help, any sample code, or any tutorials? I also found something online called FIFO and forks. Are those different from multi-thread programming?

I think that if the functions can work together, at least the functions dont need to write signal data into file and read the signal data from the file. Avoiding the file input/output will also simplify and speed-up the program.

Thanks in advance.

I would suggest you to overlap RF signal data acquisition (on CPU) and processing (on GPU). Since kernel executions are asynchronous, in principle this could be very easily done by running a device processing kernel after the RF signal data acqusition function.

To gain in effectiveness, you could think to concurrently run the kernels by using several CPU threads, each one associated to a different stream ID.

Have a look at the simpleStreams and concurrentKernels CUDA SDK examples.