![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Problem:
TASK runs too slowly in background, but runs fine in foreground. I will
be grateful for any advice.
I have a background task that monitors the COM port for GPS data, and
parses it into variables. When I run the parser in the foreground, the
variables are updated as they become available on the COM port. However,
when I run the same parser code in the background, the variables are
updated once every two or three seconds. The serial buffer then grows in
size, filling up with a backlog of COM port data that the GPS sent once
per second.
If I instead run the parser in the foreground, it quickly reads the
backlogged COM port data, catching up to the real-time GPS records.
- The GPS data is less than 400 bytes, sent at 9,600 baud, once each
second.
- SwiftForth 2.2.2.9 07May2001
- Windows 2000
- Reading COM port with COM-KEY from SIO.F
- Processor usage is around 5% with background parser running.
- A foreground task that prints the parsed variables to the SwiftForth
console raises to 100%, when the parser is running in the FOREGROUND.
- A foreground task that prints the parsed variables to the SwiftForth
console varies between 70-100%, when the parser is running in the
BACKGROUND.
- While the foreground process is not running, the background process
should catch up to the data with no display semaphores to possibly slow
it down. In any case, commenting out the semaphores did not change the
update rate.
The code below shows that both the foreground word (GFR)
and the background word (START-GPS-MONITOR)
call the same GPS parser code (GET1GPS-REC).
Could the Windows process priority be set too low? How do I change it?
How do I get GPS-MONITOR to be listed in Windows Task Manager?
Any advice will be greatly appreciated. Thanks,
- Pedro
----------------------------------------------------------
: GFR ( -- ) \ get GPS record then print until key pressed
ZERO-COUNTERS
BEGIN
GET1GPS-REC
.GPS-RECS
EKEY? UNTIL
; \ GPS-FIND-REC
8192 TASK GPS-MONITOR \ set up a background task
: START-GPS-MONITOR ( -- ) \ parse each record from GPS into vars until
killed
ZERO-COUNTERS
GPS-MONITOR ACTIVATE
BEGIN
GET1GPS-REC
AGAIN
; \ START-GPS-MONITOR
: .GPS ( -- ) \ getting GPS record in background. Now print until key
pressed
0 GPSUPDATE# !
BEGIN
.GPS-RECS
GPSUPDATE# @ 1+ DUP CR . GPSUPDATE# !
200 Sleep DROP
EKEY? UNTIL
;
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Jun 26 2003 - 11:59:17 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:32 PST