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 Dave Hylands

Hi Dave,

I don't know about AvrX, but most RTOS systems have a "ready" queue. At
each timer tick, or logical yield point (like giving a semaphore, or
when one thread blocks), the OS starts running the first entry on the
ready queue. The ready queue is normally maintained in priority order.
There's always an idle thread which does nothing and is always ready to
run.

The OS itself doesn't really do polling. Obviously, supporting devices
which don't generate interrupts would require some type of timer based
polling.

So, in an RTOS, the highest priority ready-to-run thread is always
running. Context switches occur whenever something causes a higher
priority blocked thread to become ready-to-run (say it's waiting on a
semaphore and a lower priority thread signals the semaphore). The timer
tick is used to round-robin equal priority threads.

For a UART, some thread is typically waiting for data, blocked on a
sempahore. The UART interrupt hanlder will detect that a new character
has arrived, stuff it in a queue and signal the semaphore, which may in
turn cause it to run (this is where the context switch would happen if
the thread which was waiting for a character from the UART is higher
priority than the currently running thread).

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/ 

> -----Original Message-----
> From: Dave VanHorn [mailto:dvanhorn@dvanhorn.org] 
> Sent: Tuesday, September 07, 2004 10:25 AM
> To: AVR-Chat@yahoogroups.com; AVR-Chat@yahoogroups.com
> Subject: RE: [AVR-Chat] Re: Teenagers should write code.
> 
> 
> 
> >
> >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.
> 
> Ok, so the timer isr would then be doing the polling, 
> effectively, right?
> 
> As I understand it, you would do the status bit checking 
> during the timer int, and say "task 6 and task 8 are ready to 
> run", and I would assume, put their addresses on the stack in 
> reverse order? (or something like that)

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.