discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] How is processor time given to blocks?


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] How is processor time given to blocks?
Date: Wed, 21 Jul 2010 13:33:29 -0700
User-agent: Mutt/1.5.20 (2009-08-17)

On Wed, Jul 21, 2010 at 12:58:25PM -0700, Sean Jordan wrote:
> >
> > > Thanks, with this in mind, I need in my application for only one block to
> > be
> > > running at a time. Is there any way for that to be specified?
> >
> > No.
> >
> > Why would you want only a single block running at a time?
> > Needless to say, you want to avoid shared state.
> >
> > Eric
> >
> 
> For running only at one time- My first block picks out "chunks" of data and
> passes these on to the next blocks. These "chucks" only come along once in a
> while. The blocks after only need to run when these "chucks" are found. I am
> passing a flag (1 or 0) at the beginning of the output to tell the next
> block whether or not to run. Once a "chunk" is found, each block must
> process the data after the previous block in order. Multiple blocks running
> at the same time seems to mess with my flags, causing my end data to be
> incorrect. Perhaps there is a better way to to this than Run/Don't run
> flags.
> 
> -Sean

You can easily do what you described without trying to "damage the
scheduler" :-)

Your first block should only produce output when it "feels like it".
To do this, it should derive from gr_block and implement "general_work"
instead of "work".

At the end of your general_work method, call consume or consume_each
to tell the scheduler how much input you consumed.  Your return value
from general_work is the number of output items that you produced.

Please see http://www.gnu.org/software/gnuradio/doc/howto-write-a-block.html

It's a bit out of date with regard to the build system, but is accurate
for what you are trying to do.  See the howto_square_ff example.

Your downstream block will only run when it has input available, which
will only occur when your first block generates output.  No flag is
required.

Blocks are conceptually connected by single-writer multiple-reader FIFOs.

Eric



reply via email to

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