Diminishing stack

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Diminishing stack

Post by FFMan »

Don

I have some code (a task) that read GPS data at 57600 on a zx24p using com2. Its configured to send 4 RMC records a second at the moment. The first part of the code waits for a satellite lock before carrying on.

The block of code that reads the data loops round if there is no lock. I am getting a program hang after a period of a few secs. If i double the stack size the code runs for longer. At the moment I have a 1000 byte stack which allows the code to run long enough to get a lock but clearly there is something amiss.

Strangely once a lock is acheived the same block of code works fine. By inserting debug.print system.taskheadroom, i can see in 'no lock mode' the usable stack is decreasing by 2 bytes every loop.

The code is pretty straight forward, the only 'naughty' is a goto that jumps out of the middle of a select case block when waiting for a lock. What do you think is causing my issue ? What sort of coding causes this ?

thanks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Diminishing stack

Post by dkinzer »

FFMan wrote:Strangely once a lock is acheived the same block of code works fine. By inserting debug.print system.taskheadroom, i can see in 'no lock mode' the usable stack is decreasing by 2 bytes every loop.
It is important to note that System.TaskHeadRoom does not tell you the amount of stack space that is left at any point in time. Rather, it indicates the most stack space that was used up to the point when the headroom value was taken.
FFMan wrote:What sort of coding causes this ?
It could be related to the way that you coded the routines but it could also be an issue with the code generated by the compiler. There is really no way to determine the cause without seeing the code. If you'd rather not post it here, zip up all of the source files and the project file and email it to me.
- Don Kinzer
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

have sent you the code to your email address
Post Reply