DocJC
Joined: 16 Mar 2006
Posts: 83
Location: Cleveland, OH
|
|
Posted: 05 December 2006, 16:12 PM Post subject: Que Size Question |
|
|
I appreciate everyone's patience in answering "trivial" questions...
Two questions:
I did a Site Search on the keyword GetQueueCount and get 10 hits, the first of which is:
1. [100.00%] ZBasicSysLib - page 141 of 229 available in the queue...
When I click on it it takes me to a page on the command PAUSE, which has nothing to do with ques...
Is the search searching the ZX server, or is it searching my system, which perhaps has several old versions of the references stashed on it here and there?
Followup Question:
As part of debugging I wanted to check several que sizes, to make sure they were adequate, and that the ZX-24 was never held up awaiting another Task to read several values out before it could stuff more values in.
In my initializations I have:
| Code: | 'Ques:
Public GPSQue (1 to 160) as Byte 'GPS Data Stream Que, Read
Public BTQueTx (1 to 60) as Byte 'Bluetooth Input Que, Write To BT to Transmit
Public BTQueRx (1 to 80) as Byte 'Bluetooth Output Que, Read Into ZX, RF Rx
Public MMCQue (1 to 150) as Byte 'Hold data for MMC Data Card Write routine |
In an infinite loop Task, which reads in a GPS data stream, locates the Start of packet(s), ID's them, and processes them, I inserted a couple lines to display the GPS Que size.
My intention was to debug.print the size of the que space available, and for obcessive compulsive completeness, also print the number of characters currently in the que.
I expected the numbers to add up to the total que size, as specified in the original Dim statement, but they don't.
I believe the manual says that GetQueueBufferSize() - GetQueueCount gives the space available within the que. (No pointer overhead).
My total, The slots available + The number of characters in the que = 151, Not 160, as expected, although it at least remains constant.
It would appear that the buffer is much larger than needed, but why do these values not add up the originally dimensioned que size?
Output: (QS, Space Available, # Char in Que)
QS 144 7
QS 148 3
QS 150 1
QS 151 0
QS 148 3
Code:
| Code: |
Dim QueSize as integer 'Measure Que size, make sure not running out
Dim GQC as integer 'GetQueueCount reading
Call ClearQueue (GPSQue) 'Empty the que for starters, once
Do 'Loop Forever
GQC = GetQueueCount(GPSQue) 'Read number of char in que
QueSize = GetQueueBufferSize(GPSQue) - GQC 'Gives size remaining
debug.print "QS " & CStr(QueSize) & " " & CStr(GQC)
Call GPSSOP 'Find the GPS SOP
Call GPSIDP 'ID GPS Packets: RMC, GGA, GSV, and Process them
Loop |
Clearly I'm missing something here, but I would appreciate others pointing me in the right direction!
JC |
|
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR
|
|
Posted: 05 December 2006, 16:35 PM Post subject: Re: Que Size Question |
|
|
| DocJC wrote: | Is the search searching the ZX server, or is it searching my system, which perhaps has several old versions of the references stashed on it here and there?
|
The site search returns information from a database compiled by searching the zbasic.net site. It appears that the index is stale and refers to pages that have since been updated. We'll check into what's going on there.
| DocJC wrote: | I expected the numbers to add up to the total que size, as specified in the original Dim statement, but they don't. I believe the manual says that GetQueueBufferSize() - GetQueueCount gives the space available within the que. (No pointer overhead).
|
A queue consists of a data area (whose size is returned by GetQueueBufferSize) plus some control information. The difference between GetQueueBufferSize() and SizeOf(queue) gives the number of bytes of queue management data; currently 9 bytes. This sometimes referred to as the queue overhead.
GetQueueBufferSize() - GetQueueCount() tells you how much space is left in the queue. The left side of that expression gives the size of the data area of the queue and the right side gives the number of bytes that are currently occupied in the data area.
| DocJC wrote: | | My total, The slots available + The number of characters in the que = 151, Not 160, as expected, although it at least remains constant. | The difference, 9 bytes, is the management information or queue overhead. |
|