[Tinyos-help] [PATCH] Deadlock in C sdk's write_serial_packet()
David Gay
dgay42 at gmail.com
Fri Jul 13 11:35:07 PDT 2007
On 7/3/07, Steve McKown <rsmckown at yahoo.com> wrote:
> In TinyOS 2.0.x, the C SDK's serialsource.c contains a logic error in
> write_serial_packet() that can cause a deadlock. This situation occurs when
> write_serial_packet() is called by the host and the attached mote fails to
> see the ending SYNC delimiter sent (due to a communication error). The host
> waits in read_and_process() for an ack from the mote, and the mote waits in
> RXSTATE_INFO for more data from the host. The deadlock is broken if the mote
> forwards a radio packet to the host.
I've checked in a fix for this - I believe the problem is that
write_serial_packet should always be checking for acks in non-blocking
mode even when the serial_source isn't non-blocking (as far as I can
tell, the old code would never deadlock with a non-blocking serial
source). So the fix is slightly different from the one below.
Let me know if the modified version (in CVS on the tinyos 2.x tree)
still doesn't work...
David Gay
>
> The patch below may be a suitable resolution.
>
> Cheers,
> Steve
>
> Index: serialsource.c
> ===================================================================
> --- serialsource.c (revision 1024)
> +++ serialsource.c (working copy)
> @@ -768,6 +768,9 @@
> {
> struct packet_list *entry;
>
> + if (source_wait(src, &deadline) < 0)
> + return 1;
> +
> read_and_process(src);
> entry = pop_protocol_packet(src, P_ACK);
> if (entry)
> @@ -779,8 +782,6 @@
> if (acked == src->send.seqno)
> return 0;
> }
> - else if (source_wait(src, &deadline) < 0)
> - return 1;
> }
> }
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at Millennium.Berkeley.EDU
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
More information about the Tinyos-help
mailing list