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: Sean Jordan
Subject: Re: [Discuss-gnuradio] How is processor time given to blocks?
Date: Wed, 21 Jul 2010 16:00:58 -0700


> 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
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. 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?

Sean

reply via email to

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