discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Regarding lock protection when setting private va


From: Johnathan Corgan
Subject: Re: [Discuss-gnuradio] Regarding lock protection when setting private variables in gnuradio blocks
Date: Thu, 16 Oct 2014 08:32:45 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2

On 10/16/2014 07:54 AM, address@hidden wrote:

> Is it not the case that a given instance of a block is only ever 
> executed by a single thread, so instance variables are completely
> safe to modify in-flight?

There is one thread that alternates calling the async message handlers,
the forecast function, and the work function, so variables shared only
by these three do not need protection.

However, public functions on a block are called from another thread
context (which ever thread the user calls them from), and are completely
asynchronous to the block's runtime thread.

Many public block functions in GNU Radio are not thread-safe because of
this, but in practice work fine as Tom explained.

Now that we've had the ability to use asynchronous messaging between
blocks or from outside GNU Radio into a block for quite some time, I
would encourage block developers to take advantage of their thread-safe
nature and think about how to use them to update the operations of their
blocks vs. calling public functions.

-- 
Johnathan Corgan, Corgan Labs
SDR/DSP Training and Consulting Services
http://corganlabs.com

Attachment: johnathan.vcf
Description: Vcard

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]