A7 points to the current top of a stack (always valid). The stack is
allocated in the dynamic heap.
A6 is the 'frame' pointer (sometimes valid). The frame exists on the stack.
A5 is the 'globals' pointer (sometimes valid). Globals is your apps' data,
and is allocated in the dynamic heap.

Non-preemptive multi-threading is fairly simple. It does not require copying
the stack, merely changing the stack pointer (A7). I use a homebrew
muli-threading package that supports any number of threads, complete with
sync objects and asyncronous sockets, and it works just fine. Allows all
kinds of stuff to 'run' in the background.

See me offline if you'd like info.

--------------------
Jeff Loucks
Work 425-284-1128 [EMAIL PROTECTED]
Home 253-851-8908 [EMAIL PROTECTED]
Mobile 253-691-8812


-----Original Message-----
From: Zakai Hamilton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 20, 2005 8:04 AM
To: Palm Developer Forum
Subject: Re: Cooperative Multitasking


OK... I am writing an environment for PalmOS and because its very module
oriented, I wanted Cooperative multitasking using ErrSetJump and ErrLongJump
and storing/restoring stacks via dynamic memory. Its a long story and I will
post it once it works but I am stuck on writing the saved stack back to the
real stack.

The idea is that after I use ErrLongJump to jump to the yield function to
continue the code, I want to restore the stack that was saved previously in
the yield before I used ErrSetJump there.

The funny thing is that I can save and restore a stack if I do the Save and
then the Restore function one after each other but I cannot Save in one
place and Restore in another if ErrSetJump and ErrLongJump happens
inbetween. Any ideas why that would happen? (I get the "run68k.c, Line:4425,
Unhandled instr" error when it tries to use MemMove to copy from the saved
stack to the real stack).

Note that the copying code is fine... otherwise I wouldnt able to Save to
the stack and then Restore from the stack. The problem is when I save the
stack in one place of execution and restore it at another location.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to