Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] Re: Teenagers should write code.

2004-09-07 by Larry Barello

AvrX (my RTOS) works similarly: there is no polling.  An event (implemented
as a call to the RTOS) causes some queues to shift and (potentially) a
different task is running upon exit.  Polling a bunch of bits in the depths
of a kernel is one way to do things, but not the only way.  Events are just
software interrupts and can be generated via either an interrupt handler or
another task.

In AvrX the interrupt handler usually just tickles an event and that wakes
up the task that does what it is suppose to do.  With serial I/O things are
a tad more complicated since you have to do something to make the interrupt
source go away (read or write the UDR).

In your example, below, things that don't generate interrupts need to be
polled.  There is no way to get around that.  In AvrX the way to handle that
is  to put a little code into the timer interrupt handler that generates the
"handshake" event when state changes and then have the task wait on the
handshake event.

Cheers!
----
Larry Barello
http://www.barello.net

-----Original Message-----
From: Dave VanHorn

>
>No, this is not true. My cooperative multi-tasking operating system,
>ECROS (see http://ecros.ecrostech.com), includes an event mechanism.
>There is no polling. When an event is sent to a task, the task is
>queued for execution if that event causes its ready condition to be
>satisfied. I suppose you could say that the queues are polled, but I
>think this would be stretching the definition of polling a bit far.

Ok, so there is then a list of tasks that are ready to be executed, which
you drop through. Eventually, you hit the end, and start over, or just sit
in a loop waiting for more tasks to do?

How exactly do you "send" an event to a task?

In terms I'm familiar with (I'm an assembler kind of guy), I might be
sending data to a UART.

First, I'd check wether handshake allows anything to be sent.
sbis PORTA,HSIN
ret


Second, I'd check wether the UART is actively sending something.
SBIC Ser_Flags,SER_TX_Busy
ret


Third, I'd check wether there's anything in the serial out buffer, to send.
Point at buffer, call circ_get, returns carry set if nothing in the buffer,
otherwise returns carry clear, and the next byte to send.
brcs to label with return

If all these tests pass, then I put the byte to send in a single SRAM
location, set the baud rate timer (software UART) to a minimum interval to
trigger a timer int, and exit.

The int then causes the start bit, data bits, and stop bit to be sent, then
the uart is marked as "not busy".






Yahoo! Groups Links

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.