CallBackStreaming threading concurency

Post your C and C++ discussions here
Post Reply
bennog
Advanced User
Advanced User
Posts: 206
Joined: Mon Nov 26, 2012 9:16 am
Location: Netherlands

CallBackStreaming threading concurency

Post by bennog »

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

Hitesh

Re: CallBackStreaming threading concurency

Post by Hitesh »

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,

Post Reply