[Gambas-user] High CPU usage when using serialport component
Benoît Minisini
gambas at ...1...
Sat Aug 11 12:57:41 CEST 2012
Le 11/08/2012 12:26, Christer Johansson a écrit :
> Noticed a very high CPU usage when using the serialport on a
> Raspberry Pi running Debian Squeeze and trying to understand
> whats causing it...
>
> Just opening the serialport in the SerialPort demo takes 12-26%
> depending on if using the built in serialport (/dev/ttyAMA0) or
> if using a standard USB to TLL converter (/dev/ttyUSB0)
>
> Serial Port Demo - /dev/ttyAMA0 opened @ 9600 8N1
>
> PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
> 22287 christer 20 0 30720 9284 7504 S 12.0 3.9 0:09.30 gbr3
> /home/christer/Gambas 3/Projekt/SerialPort/SerialPort.gambas
>
> Serial Port Demo - /dev/ttyUSB0 opened @ 9600 8N1.
>
> PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
> 23970 christer 20 0 30852 9372 7524 S 26.0 4.0 1:05.15 gbr3
> /home/christer/Gambas 3/Projekt/SerialPort/SerialPort.gambas
>
> Above readings are from htop and attached are also a screenshot
> showing the CPU graph in Xfce.
>
> Are anyone of you other Raspberry Pi users experiencing the same?
>
> The serialport seems to work OK (at least on 9600 8N1) but it seems
> quite wierd that so much CPU is used just for listening on a serialport,
> any ideas?
>
> /CJ
>
As the SerialPort example asks for DTR, RNG, ... Change events, the
gb.net component watches if serial port file device is ready for writing
and uses that to watch the serial port signals.
So I guess the watch callback is called again and again (i.e. the serial
port device is always ready for writing). There is a one millisecond
sleep inside the callback so that not to much CPU is consumed, but RPi
is a slow machine.
To confirm that, can you use gdb to run the exemple, hit CTRL+C during
the high CPU usage, and show me what the backtrace is then?
Thanks in advance.
Regards,
--
Benoît Minisini
More information about the User
mailing list