Test and Measurement Forum

CallBackStreaming threading concurency

Post your C and C++ discussions here

CallBackStreaming threading concurency

Postby bennog » Wed Jun 28, 2017 8:57 am

I was looking at the PS4000 streaming functions and noticed the following.

in the CallBackStreaming function the global variables g_sampleCount and g_ready are set before the data is copied to the application buffers.

In single threaded applications (and the pico core is also single threaded) this won't be a problem.
In multi threaded application this will produce corrupted data depending on what thread runs when.
It won't crash the application, because all memory locations are ok, but the data can be partly new data and partly old data, what part is old and what is new is depending on the implementation of memcpy library function.

The same construction is uesed in most of the other SDK samples also.

Benno
bennog
Advanced User
Advanced User
 
Posts: 90
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

Re: CallBackStreaming threading concurency

Postby Hitesh » Mon Jul 03, 2017 2:56 pm

Hi Benno,

Thank you for the feedback.

The example for the ps4000 driver has been updated on our GitHub repository and we will review the other examples as well.

The examples provided are for guidance and can be modified to suit the end application. You can also submit Pull Requests on GitHub and we will review suggested changes.

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2457
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests