Discussion:
[Discuss-gnuradio] About closing flowgraph automatically
Simone Ciccia S210664
2016-07-21 07:32:19 UTC
Permalink
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
to transmit, for example, in a situation like the following:

FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK

Thank for yours support and for the great utility of the list 😊
simone
Martin Braun
2016-07-22 16:40:09 UTC
Permalink
Simone,

a file source *will* terminate the flow graph once its read the file
(unless you specify 'repeat').

M
Post by Simone Ciccia S210664
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK
Thank for yours support and for the great utility of the list 😊
simone
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Piotr Krysik
2016-07-23 06:43:10 UTC
Permalink
Hi Simone and all,

Can you provide your GRC flow-graph? I think that source of the problem
might be somewhere in this part
"PMT MESSAGE TO FILE SOURCE" as there is message to samples stream
conversion involved here. But it's not clear for me what it actually is
as you described it.

I have problems with automatic closing of a flow-graph that uses a block
that converts messages to samples. In my case it is PDU to Tagged Stream
block that caused problems with automatic exiting of the flow-graph.

The constant problems with exiting of flow-graphs lead me to think if
these problems can be solved once for all with some change in gnuradio's
internals.

Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph. This tag would be processed by all blocks and would
cause them to be marked as ready for the program exit. Blocks that have
stream inputs and message outputs would convert the tag to an "exit"
message, which would be propagated through the outputs.
Blocks with message inputs ans stream outputs would convert "exit"
message to an "exit" tag. When all blocks would be marked as ready for
closing the program would end.

In this concept there is problem how to propagate the information to
blocks upstream, that might not have information about ending of a
flow-graph. So the method I described might be used as an addition to
current method of ending flowgraphs.

What do you think?

Best Regards,
Piotr Krysik
Post by Martin Braun
Simone,
a file source *will* terminate the flow graph once its read the file
(unless you specify 'repeat').
M
Post by Simone Ciccia S210664
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK
Thank for yours support and for the great utility of the list 😊
simone
Marcus Müller
2016-07-23 09:55:49 UTC
Permalink
Hi Piotr,
Post by Piotr Krysik
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph.
In fact, GR does have something like that: It's a built-in message
handler for a message port called "system"; see block.cc:60:

60 message_port_register_in(pmt::mp("system"));
61 set_msg_handler(pmt::mp("system"), boost::bind(&block::system_handler, this, _1));

You can send a "done" message there, and the block will set it's
internal state to being done, ie work won't be called any more, the
stream and message neighbours of that block will be informed to be done,
too.

By the way, the information you're looking for mainly resides in
block.cc, block_executor.cc's "run_one_iteration" method, and
tpb_thread_body.cc

It's exactly the mechanism that happens when a block notifies its
message neighbours to be done; for example, let ==> be a stream
connection and --> a message connection

msg_burster ---> some_kind_of_msg_to_stream ==> multiply_const ==> head
==> file_sink

at some point, head's work method will tell the scheduler it's done. The
scheduler will then inform head's stream neighbours (because head
doesn't have any message neighbours) that they should be done, too.

So file sink closes its file, mutliply_const is told to stop, and
multiply_const then notifies its stream neighbours itself, and thus,
some_kind_of_msg_to_stream is told to stop doing its thing, too.

However, if these neigbours (which, remember, are all independently
running threads!) are currently in their work() methods, then the
scheduler won't (can't) interrupt that work call. That's all fine for
things like multiply_const, where the work() will be done as soon as it
has gone through the chunk of samples it's currently processing.

For stream sources such as some_kind_of_msg_to_stream, the problem is a
little more complex:

Stream sources are usually designed to be blocking in the work() method;
if that blocking doesn't have some timeout, then there's no way for that
block's work() to ever stop blocking, and hence, the flow graph won't
shut down, because the "system" message handler never gets called. In
the some_kind_of_msg_to_stream source, the programmer must take care not
to block in work() if there's nothing to produce, but just return 0 -
meaning the source didn't produce anything. In the olden,
pre-message-passing days, that would've been a great mistake, because a
source producing nothing although there was the whole output buffer in
space was declared finished, but nowadays, the scheduler can "revive" a
source block not only when the free space in the output changes, but
also if there's new messages to be handled. HOWEVER: this might still
have bugs, and it might be that this is what you're encountering.
Debugging your flowgraphs on a C++ and threat level when they ought to
be exiting would be pretty interesting!

Best regards,

Marcus
Post by Piotr Krysik
Hi Simone and all,
Can you provide your GRC flow-graph? I think that source of the problem
might be somewhere in this part
"PMT MESSAGE TO FILE SOURCE" as there is message to samples stream
conversion involved here. But it's not clear for me what it actually is
as you described it.
I have problems with automatic closing of a flow-graph that uses a block
that converts messages to samples. In my case it is PDU to Tagged Stream
block that caused problems with automatic exiting of the flow-graph.
The constant problems with exiting of flow-graphs lead me to think if
these problems can be solved once for all with some change in gnuradio's
internals.
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph. This tag would be processed by all blocks and would
cause them to be marked as ready for the program exit. Blocks that have
stream inputs and message outputs would convert the tag to an "exit"
message, which would be propagated through the outputs.
Blocks with message inputs ans stream outputs would convert "exit"
message to an "exit" tag. When all blocks would be marked as ready for
closing the program would end.
In this concept there is problem how to propagate the information to
blocks upstream, that might not have information about ending of a
flow-graph. So the method I described might be used as an addition to
current method of ending flowgraphs.
What do you think?
Best Regards,
Piotr Krysik
Post by Martin Braun
Simone,
a file source *will* terminate the flow graph once its read the file
(unless you specify 'repeat').
M
Post by Simone Ciccia S210664
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK
Thank for yours support and for the great utility of the list 😊
simone
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Piotr Krysik
2016-07-23 17:41:07 UTC
Permalink
Hi Marcus,
Post by Marcus Müller
Debugging your flowgraphs on a C++ and threat level when they ought to
be exiting would be pretty interesting!
An example of my flowgraph where I used PDU to tagged stream convertion
is this:
https://github.com/ptrkrysik/examples/blob/master/voice_decoding_in_grc/tch_f_reception.grc

Messages with GSM coded voice frames are turned into stream so they can
be decoded with GSM full-rate audio decoder and played in gnuradio audio
sink.

This might be too big flow-graph for the purpose of debugging, so I
prepared minimal working example presenting the problem. The flowgraph
and its input file are attached to this post. If you want to run it in
GRC you will have to correct the File option of the file meta source to
absolute path to the tagged_stream file. I don't know how to do relative
paths in GRC yet.

Best Regards,
Piotr
Post by Marcus Müller
Hi Piotr,
Post by Piotr Krysik
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph.
In fact, GR does have something like that: It's a built-in message
60 message_port_register_in(pmt::mp("system"));
61 set_msg_handler(pmt::mp("system"), boost::bind(&block::system_handler, this, _1));
You can send a "done" message there, and the block will set it's
internal state to being done, ie work won't be called any more, the
stream and message neighbours of that block will be informed to be done,
too.
By the way, the information you're looking for mainly resides in
block.cc, block_executor.cc's "run_one_iteration" method, and
tpb_thread_body.cc
It's exactly the mechanism that happens when a block notifies its
message neighbours to be done; for example, let ==> be a stream
connection and --> a message connection
msg_burster ---> some_kind_of_msg_to_stream ==> multiply_const ==> head
==> file_sink
at some point, head's work method will tell the scheduler it's done. The
scheduler will then inform head's stream neighbours (because head
doesn't have any message neighbours) that they should be done, too.
So file sink closes its file, mutliply_const is told to stop, and
multiply_const then notifies its stream neighbours itself, and thus,
some_kind_of_msg_to_stream is told to stop doing its thing, too.
However, if these neigbours (which, remember, are all independently
running threads!) are currently in their work() methods, then the
scheduler won't (can't) interrupt that work call. That's all fine for
things like multiply_const, where the work() will be done as soon as it
has gone through the chunk of samples it's currently processing.
For stream sources such as some_kind_of_msg_to_stream, the problem is a
Stream sources are usually designed to be blocking in the work() method;
if that blocking doesn't have some timeout, then there's no way for that
block's work() to ever stop blocking, and hence, the flow graph won't
shut down, because the "system" message handler never gets called. In
the some_kind_of_msg_to_stream source, the programmer must take care not
to block in work() if there's nothing to produce, but just return 0 -
meaning the source didn't produce anything. In the olden,
pre-message-passing days, that would've been a great mistake, because a
source producing nothing although there was the whole output buffer in
space was declared finished, but nowadays, the scheduler can "revive" a
source block not only when the free space in the output changes, but
also if there's new messages to be handled. HOWEVER: this might still
have bugs, and it might be that this is what you're encountering.
Debugging your flowgraphs on a C++ and threat level when they ought to
be exiting would be pretty interesting!
Best regards,
Marcus
Post by Piotr Krysik
Hi Simone and all,
Can you provide your GRC flow-graph? I think that source of the problem
might be somewhere in this part
"PMT MESSAGE TO FILE SOURCE" as there is message to samples stream
conversion involved here. But it's not clear for me what it actually is
as you described it.
I have problems with automatic closing of a flow-graph that uses a block
that converts messages to samples. In my case it is PDU to Tagged Stream
block that caused problems with automatic exiting of the flow-graph.
The constant problems with exiting of flow-graphs lead me to think if
these problems can be solved once for all with some change in gnuradio's
internals.
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph. This tag would be processed by all blocks and would
cause them to be marked as ready for the program exit. Blocks that have
stream inputs and message outputs would convert the tag to an "exit"
message, which would be propagated through the outputs.
Blocks with message inputs ans stream outputs would convert "exit"
message to an "exit" tag. When all blocks would be marked as ready for
closing the program would end.
In this concept there is problem how to propagate the information to
blocks upstream, that might not have information about ending of a
flow-graph. So the method I described might be used as an addition to
current method of ending flowgraphs.
What do you think?
Best Regards,
Piotr Krysik
Post by Martin Braun
Simone,
a file source *will* terminate the flow graph once its read the file
(unless you specify 'repeat').
M
Post by Simone Ciccia S210664
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK
Thank for yours support and for the great utility of the list 😊
simone
Marcus Müller
2016-07-23 18:30:29 UTC
Permalink
Hi Piotr,

I let gdb loose on your minimal example [1], and found this:

52 int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }

Sylvain, who replaced the delete_head_nowait with the
delete_head_blocking call correctly pointed out the reason to do so in
blocks: Fix pdu_to_tagged_stream CPU spinning using blocking with timeout
This is not ideal, but until the scheduler supports something better, this
will have to do.
Problem is that if we use the non-blocking call here, the scheduler
would have a chance to process the shutdown signal, but it would be
constantly asking (spinning) for the output stream length.

You could try out what would happen if we'd added a timeout to the
blocking cal; that way, you could reduce the spinning, and hopefully get
the scheduler to check for "done" messages. For tagged stream blocks, my
knowledge of the scheduler control flow isn't as reliable as for regular
blocks :/

Best regards,

Marcus

[1] http://marcus.hostalia.de/screencast/run_to_completion.html
Hi Marcus,
Post by Marcus Müller
Debugging your flowgraphs on a C++ and threat level when they ought to
be exiting would be pretty interesting!
An example of my flowgraph where I used PDU to tagged stream convertion
https://github.com/ptrkrysik/examples/blob/master/voice_decoding_in_grc/tch_f_reception.grc
Messages with GSM coded voice frames are turned into stream so they can
be decoded with GSM full-rate audio decoder and played in gnuradio audio
sink.
This might be too big flow-graph for the purpose of debugging, so I
prepared minimal working example presenting the problem. The flowgraph
and its input file are attached to this post. If you want to run it in
GRC you will have to correct the File option of the file meta source to
absolute path to the tagged_stream file. I don't know how to do relative
paths in GRC yet.
Best Regards,
Piotr
Post by Marcus Müller
Hi Piotr,
Post by Piotr Krysik
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph.
In fact, GR does have something like that: It's a built-in message
60 message_port_register_in(pmt::mp("system"));
61 set_msg_handler(pmt::mp("system"), boost::bind(&block::system_handler, this, _1));
You can send a "done" message there, and the block will set it's
internal state to being done, ie work won't be called any more, the
stream and message neighbours of that block will be informed to be done,
too.
By the way, the information you're looking for mainly resides in
block.cc, block_executor.cc's "run_one_iteration" method, and
tpb_thread_body.cc
It's exactly the mechanism that happens when a block notifies its
message neighbours to be done; for example, let ==> be a stream
connection and --> a message connection
msg_burster ---> some_kind_of_msg_to_stream ==> multiply_const ==> head
==> file_sink
at some point, head's work method will tell the scheduler it's done. The
scheduler will then inform head's stream neighbours (because head
doesn't have any message neighbours) that they should be done, too.
So file sink closes its file, mutliply_const is told to stop, and
multiply_const then notifies its stream neighbours itself, and thus,
some_kind_of_msg_to_stream is told to stop doing its thing, too.
However, if these neigbours (which, remember, are all independently
running threads!) are currently in their work() methods, then the
scheduler won't (can't) interrupt that work call. That's all fine for
things like multiply_const, where the work() will be done as soon as it
has gone through the chunk of samples it's currently processing.
For stream sources such as some_kind_of_msg_to_stream, the problem is a
Stream sources are usually designed to be blocking in the work() method;
if that blocking doesn't have some timeout, then there's no way for that
block's work() to ever stop blocking, and hence, the flow graph won't
shut down, because the "system" message handler never gets called. In
the some_kind_of_msg_to_stream source, the programmer must take care not
to block in work() if there's nothing to produce, but just return 0 -
meaning the source didn't produce anything. In the olden,
pre-message-passing days, that would've been a great mistake, because a
source producing nothing although there was the whole output buffer in
space was declared finished, but nowadays, the scheduler can "revive" a
source block not only when the free space in the output changes, but
also if there's new messages to be handled. HOWEVER: this might still
have bugs, and it might be that this is what you're encountering.
Debugging your flowgraphs on a C++ and threat level when they ought to
be exiting would be pretty interesting!
Best regards,
Marcus
Post by Piotr Krysik
Hi Simone and all,
Can you provide your GRC flow-graph? I think that source of the problem
might be somewhere in this part
"PMT MESSAGE TO FILE SOURCE" as there is message to samples stream
conversion involved here. But it's not clear for me what it actually is
as you described it.
I have problems with automatic closing of a flow-graph that uses a block
that converts messages to samples. In my case it is PDU to Tagged Stream
block that caused problems with automatic exiting of the flow-graph.
The constant problems with exiting of flow-graphs lead me to think if
these problems can be solved once for all with some change in gnuradio's
internals.
Maybe it can be some "exit" tag that would be propagated to all blocks
in a flowgraph. This tag would be processed by all blocks and would
cause them to be marked as ready for the program exit. Blocks that have
stream inputs and message outputs would convert the tag to an "exit"
message, which would be propagated through the outputs.
Blocks with message inputs ans stream outputs would convert "exit"
message to an "exit" tag. When all blocks would be marked as ready for
closing the program would end.
In this concept there is problem how to propagate the information to
blocks upstream, that might not have information about ending of a
flow-graph. So the method I described might be used as an addition to
current method of ending flowgraphs.
What do you think?
Best Regards,
Piotr Krysik
Post by Martin Braun
Simone,
a file source *will* terminate the flow graph once its read the file
(unless you specify 'repeat').
M
Post by Simone Ciccia S210664
Goodmorning,
I would like to Know some methods to Close flowgraph automatically when
it has finished. Some example, stop when USRP has no more samples to
transmits, or a file source has read until EOF.
The Run of completion option works when (for instance) you have a file
source connected to other non-PMT Message block and a sink (USRP or null
sink...). However, when the file source output is converted to pmt
Message, then the flowgraph does not stop anymore when rhe file source
has finished. Probably because the PMT Message block continue to waits
for messages. In this case, How I can stop automatically the flowgraph?
I would like to Close the flowgraph when EOF or USRP has no more sample
FILE SOURCE -> STREAM TO PMT MESSAGE -> PROCESSING BLOCKS -> PMT MESSAGE
TO FILE SOURCE -> USRP SINK
Thank for yours support and for the great utility of the list 😊
simone
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Sylvain Munaut
2016-07-24 06:04:25 UTC
Permalink
Hi,
Post by Marcus Müller
52 int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the scheduler would have a chance to process the shutdown signal, but it would be constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the blocking cal; that way, you could reduce the spinning, and hopefully get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.


Cheers,

Sylvain
Simone Ciccia S210664
2016-07-24 07:16:10 UTC
Permalink
Goodmorning list,
thanks to everybody for your replies.

I attached a minimal example illustrating the problem.
Specifically, the block that causes the non stop behavior is the
[PDU to tagged stream], the same encountered by Piotr and discussed in
the other replies.

In my case we can restrict this problem in how to signal to PDU to
tagged stream to finish.
If I understand, correct me Marcus, for PDU to tagged stream I need to
use some timeout to monitoring input message.
When timeout expires and no input message is present, then the block
returns zero.
This is exactly what PDU to tagget stream does:

52 int
pdu_to_tagged_stream_impl::calculate_output_stream_length(const
gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the
best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }

My doubt is, how can we signal and stop the execution of this block?
If there some idea I have time to trying to thinking to
modify/ameliorate this block and discuss with you.
Thank you,
simone
Post by Sylvain Munaut
Hi,
Post by Marcus Müller
52 int
pdu_to_tagged_stream_impl::calculate_output_stream_length(const
gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the scheduler
would have a chance to process the shutdown signal, but it would be
constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the
blocking cal; that way, you could reduce the spinning, and hopefully
get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Marcus Müller
2016-07-24 08:55:54 UTC
Permalink
Hi,

'doh.

Which leaves one to wonder why the finished state never gets checked.
I'll be back after a bit of tracing.

Cheers,

Marcus
Post by Sylvain Munaut
Hi,
Post by Marcus Müller
52 int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the scheduler would have a chance to process the shutdown signal, but it would be constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the blocking cal; that way, you could reduce the spinning, and hopefully get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
Marcus Müller
2016-07-24 10:39:38 UTC
Permalink
If I had to pinpoint a culprit, it'd be in gnuradio-runtime/lib/block.cc

750 bool
751 block::finished()
752 {
753 if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
754 return false;
755 else
756 return d_finished;
757 }
758

Meaning that blocks with any stream in- or output can't be finished(),
and hence, execution will only stop if the blocks are in- or output
blocked, or the work function explicitely returned WORK_DONE(==-1),
which probably works quite well for stream-only flowgraphs.

However, that "if" was added but a year ago – and likely for a good
reason, that I don't see right now. Maybe someone else could have a look
at this?

Greetings,

Marcus
Post by Marcus Müller
Hi,
'doh.
Which leaves one to wonder why the finished state never gets checked.
I'll be back after a bit of tracing.
Cheers,
Marcus
Post by Sylvain Munaut
Hi,
Post by Marcus Müller
52 int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the scheduler would have a chance to process the shutdown signal, but it would be constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the blocking cal; that way, you could reduce the spinning, and hopefully get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
Bastian Bloessl
2016-07-24 19:18:08 UTC
Permalink
Maybe you want to try the flow graph with the next branch. What you describe was supposed to be addressed by

https://github.com/gnuradio/gnuradio/pull/797

Best,
Bastian
Post by Marcus Müller
If I had to pinpoint a culprit, it'd be in gnuradio-runtime/lib/block.cc
750 bool
751 block::finished()
752 {
753 if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
754 return false;
755 else
756 return d_finished;
757 }
758
Meaning that blocks with any stream in- or output can't be finished(),
and hence, execution will only stop if the blocks are in- or output
blocked, or the work function explicitely returned WORK_DONE(==-1),
which probably works quite well for stream-only flowgraphs.
However, that "if" was added but a year ago – and likely for a good
reason, that I don't see right now. Maybe someone else could have a look
at this?
Greetings,
Marcus
Post by Marcus Müller
Hi,
'doh.
Which leaves one to wonder why the finished state never gets checked.
I'll be back after a bit of tracing.
Cheers,
Marcus
Post by Sylvain Munaut
Hi,
Post by Marcus Müller
52 int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the scheduler would have a chance to process the shutdown signal, but it would be constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the blocking cal; that way, you could reduce the spinning, and hopefully get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--
Dipl.-Inform. Bastian Bloessl
Distributed Embedded Systems Group
University of Paderborn, Germany
http://www.ccs-labs.org/~bloessl/
Marcus Müller
2016-07-24 19:31:33 UTC
Permalink
Ah, great! This is really the patchset of my dreams :D

Thanks! Should've thought of checking out next
 or the redmine issue
tracker. Must be the heat.

Cheers,

Marcus
Post by Bastian Bloessl
Maybe you want to try the flow graph with the next branch. What you
describe was supposed to be addressed by
https://github.com/gnuradio/gnuradio/pull/797
Best,
Bastian
Post by Marcus Müller
If I had to pinpoint a culprit, it'd be in
gnuradio-runtime/lib/block.cc <http://block.cc>
750 bool
751 block::finished()
752 {
753 if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
754 return false;
755 else
756 return d_finished;
757 }
758
Meaning that blocks with any stream in- or output can't be finished(),
and hence, execution will only stop if the blocks are in- or output
blocked, or the work function explicitely returned WORK_DONE(==-1),
which probably works quite well for stream-only flowgraphs.
However, that "if" was added but a year ago – and likely for a good
reason, that I don't see right now. Maybe someone else could have a look
at this?
Greetings,
Marcus
Post by Marcus Müller
Hi,
'doh.
Which leaves one to wonder why the finished state never gets checked.
I'll be back after a bit of tracing.
Cheers,
Marcus
Post by Sylvain Munaut
Hi,
Post by Marcus Müller
52 int
pdu_to_tagged_stream_impl::calculate_output_stream_length(const
gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Post by Marcus Müller
Problem is that if we use the non-blocking call here, the
scheduler would have a chance to process the shutdown signal, but
it would be constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the
blocking cal; that way, you could reduce the spinning, and
hopefully get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--
Dipl.-Inform. Bastian Bloessl
Distributed Embedded Systems Group
University of Paderborn, Germany
http://www.ccs-labs.org/~bloessl/ <http://www.ccs-labs.org/%7Ebloessl/>
Simone Ciccia S210664
2016-07-27 07:05:20 UTC
Permalink
Hi,
I would like to thank you for the support,
my issue is entirely solved applying the patch suggested in #797

Cheers :-)
Post by Marcus Müller
Ah, great! This is really the patchset of my dreams :D
Thanks! Should've thought of checking out next… or the redmine issue
tracker. Must be the heat.
Cheers,
Marcus
Post by Bastian Bloessl
Maybe you want to try the flow graph with the next branch. What you
describe was supposed to be addressed by
https://github.com/gnuradio/gnuradio/pull/797
Best,
Bastian
If I had to pinpoint a culprit, it'd be in
gnuradio-runtime/lib/block.cc [1]
750 bool
751 block::finished()
752 {
753 if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
754 return false;
755 else
756 return d_finished;
757 }
758
Meaning that blocks with any stream in- or output can't be
finished(),
and hence, execution will only stop if the blocks are in- or output
blocked, or the work function explicitely returned WORK_DONE(==-1),
which probably works quite well for stream-only flowgraphs.
However, that "if" was added but a year ago – and likely for a good
reason, that I don't see right now. Maybe someone else could have a look
at this?
Greetings,
Marcus
Hi,
'doh.
Which leaves one to wonder why the finished state never gets
checked.
I'll be back after a bit of tracing.
Cheers,
Marcus
Hi,
52 int
pdu_to_tagged_stream_impl::calculate_output_stream_length(const
gr_vector_int &)
53 {
54 if (d_curr_len == 0) {
55 /* FIXME: This blocking call is far from ideal but is the best we
56 * can do at the moment
57 */
58 pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID, 100));
59 if (msg.get() == NULL) {
60 return 0;
61 }
[snip]
Problem is that if we use the non-blocking call here, the scheduler
would have a chance to process the shutdown signal, but it would be
constantly asking (spinning) for the output stream length.
You could try out what would happen if we'd added a timeout to the
blocking cal; that way, you could reduce the spinning, and hopefully
get the scheduler to check for "done" messages.
There _is_ a timeout ... that "100" in there is the # of millisec to
wait at most.
Cheers,
Sylvain
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
--
Dipl.-Inform. Bastian Bloessl
Distributed Embedded Systems Group
University of Paderborn, Germany
http://www.ccs-labs.org/~bloessl/ [2]
------
[1] http://block.cc
[2] http://www.ccs-labs.org/%7Ebloessl/
_______________________________________________
Discuss-gnuradio mailing list
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Loading...