This loop does all your work. Without it your block is useless. :)

To know how the scheduler chooses the value of items that are passed into
the work() function I suggest you look into scheduler's code. It's a fairly
easy to understand C++ code and most of your answers will be answered.

According to my knowledge the work() function always returns the number of
items consumed by your block each time the work() function is called. When
you return from work() you are basically informing the scheduler how many
items were consumed so that the scheduler doesn't discard the unused input
data. Believe me I once did the same mistake of not returning and had a
troubling time knowing why my block wasn't working as it was supposed to be.

On Thu, Jul 15, 2010 at 3:02 AM, Sammour <samy-1...@live.com> wrote:

>
> I have a basic question regarding GNURadio scheduler and how the flowgraph
> works. I am using gr_sync_block but my question are valid for gr_block
>
> From the online tutorial about how to write a block I read:
>
>  87    for (int i = 0; i < noutput_items; i++){
>  88      out[i] = in[i] * in[i];
>  89    }
>
> I could print noutput_items and it is a huge number in order of thousands.
> So my question is why should I create this loop? and how does it work? I
> have read somewhere in this discution board that not using this loop will
> increase the calclation overhead but no clue why. Does my block outputs the
> items "bunch by bunch" or item by item.
>
> Another question here: I saw few programs which dont return noutput_items
> from work or general_work so it seems that I dont have to always return it.
> How can I determine the value I shoud return.
>
> Cheers,
>
> Sam
> --
> View this message in context:
> http://old.nabble.com/How-do-the-Scheduler-and-the-flowgraph-work--tp29171158p29171158.html
> Sent from the GnuRadio mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to