I thought folks here might be interested in the results of an experiment
we ran recently.  The motivation was the interaction of TOS_post and the
very tight real-time deadline for the SPI interrupt handler.

The problem is that TOS_post disables interrupts for long enough that if
the SPI interrupt handler arrives while ints are disabled a bit can be
lost, leading to packet loss from checksum failure.  We found that
posting 500 tasks per second on a mica mote causes significant packet
loss and posting 1000 tasks per second causes the radio to operate at
about 1/2 performance (measured using a ping-pong test).

The solution is to borrow a trick from RTLinux and do a lightweight
virtualization of the SPI interrupt handler.  This leads to the
following program transformation:

  cli() / sei() become "disable / enable all interrupts except SPI"

  The SPI interrupt handler is divided into two phases:

  A "real" interrupt handler that interacts with hardware (only a couple
  of instructions) and then signals a software interrupt.  This
  interrupt is only disabled by TinyOS for very brief periods and,
  therefore, should miss very few deadlines.

  A software interrupt handler that integrates the result of the real
  interrupt handler into the ongoing computation (that is, this is what
  used to be the main body of the SPI interrupt handler).  Since the
  software interrupt is masked by the transformed cli() no races are
  introduced.

We found that the transformed code can tolerate 5000 and 10000 TOS_post
operations per second without noticeable packet loss.  Of course,
overhead is added due to the more complex interrupt masking, so this
transformation is probably only worth it in programs that post tasks
frequently.

John Regehr

_______________________________________________
Tinyos-users mailing list
[EMAIL PROTECTED]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users

Reply via email to