Click here to Skip to main content
15,885,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello, everybody. I have a problem about The design about real-time data reception,treatment and save. I have a read(cBuf,length) function to receive real-time data.
I make a core exclusive thread with SetThreadAffinityMask(). In this thread, it have the read function and treatment etc. Recently I found that the thread lost frame one and then. By analyzing ,It is because too slow to read data in time.
So I want divide into two thread, one only achieve the read() function, and other things are covered by the other. However I found if add critical or lock still too slow, of course maybe my bad program is the main reason.
Now, I want get a solution about my problem. A real-time no-lock queue or something else?
Could you give me some advice or example.
Posted

1 solution

It is difficult to outline a winning strategy based just on the details you posted. Possibly you might just improve the performance of your code (fine tuning it). Possibly the algorithm could be actually parallelized to exploit the multicore (I assume it is) CPU. Possibly, lastly, you simply cannot handle real time such of input data rate and have to fatally lose some frames.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Aug-15 11:55am    
As far as I understand, the OS is Windows. It is not a real-time OS in not sense of this word, period.
—SA
CPallini 23-Aug-15 11:59am    
As far as I understand, the OP meant 'process data as soon as they arrive' with 'real time'.
Sergey Alexandrovich Kryukov 23-Aug-15 12:24pm    
One thing is related to another. Things as thread affinity mask, as well as thread priorities, can just improve the probability that all "loosing some frames" won't happen, but never 100%...
—SA
CPallini 23-Aug-15 13:09pm    
Suppose you have a device connected to the PC via the serial port. Now, notwithstanding you cannot gather the individual bytes in a real time fashion, you usually are able to collect packets an process them.
Sergey Alexandrovich Kryukov 23-Aug-15 20:08pm    
Of course, but it cannot be real time. Usually, this is the acquisition driven by the host computer.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900