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 17:12:41 -0700
User-agent: Mutt/1.5.20 (2009-08-17)

On Wed, Jul 21, 2010 at 04:00:58PM -0700, Sean Jordan wrote:
> >
> > 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
> >
> Thanks. That helped a lot, however the code seems to be looping in one of
> the secondary blocks before proceeding to the next blocks or going back to
> the first block. I cannot figure out what is causing this.

Write a piece of QA code to test your block with known inputs and
expected outputs.  There are tons of examples in
gnuradio-core/src/python/gnuradio/gr/qa_*.py

> I think it may
> have to do with ninput_items or noutput_items but am not sure. From what I
> can tell, ninput_items should be the number returned by general_work in the
> previous block,

> however how does one use that number when it is a vector and what is its 
> purpose?

ninput_items tells you many items are available on each of your input
streams.  ninput_items[0] is the number of items of input available on
input stream 0...

You may not need to look at it depending on your needs.  Unless you
override "forecast", the default version will tell the scheduler that
you need 1 input for each output item to be produced.

The relationship between forecast and general_work is explained in the
howto-write-a-block doc mentioned above.

You should treat each block as a black box, unrelated to the blocks
upstream or downstream from it.  If you're thinking that they are
related, or are trying to second guess the scheduler wrt noutput_items
or the amount of input available when your general_work function is
called, you're headed for trouble.

Eric



reply via email to

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