Hi,

It seems you are always busy-waiting on the UART interrupt in the Linux driver
(with code such as "while(!(lm32_irq_pending() & (1 << IRQ_UARTTX)))")

This is a bad idea since it locks up the CPU every time the UART is 
transmitting.

For a more efficient solution, you can use a "CTS" (Clear To Send) state 
variable as follows:

* Transmission of a character
If CTS=1: send the character to the HW, set CTS=0
If CTS=0: put the character into a software FIFO (I guess Linux does that by 
default)

* TX interrupt handler (IRQ is sent by the HW as soon as transmission is done)
If the software FIFO is empty, set CTS=1
If the software FIFO is not empty, pull a character from it and send it to the 
HW

This algorithm of course requires locking (i.e. mask the UART interrupt during 
the "character transmission" routine).

For an example implementation, check out:
http://github.com/lekernel/milkymist/blob/master/software/libbase/uart-async.c

Can you implement this method in Linux to improve CPU efficiency?

Thanks,
Sébastien
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkym...@freenode
Webchat: www.milkymist.org/irc.html
Wiki: www.milkymist.org/wiki

Reply via email to