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

I haven't worked on your specific target, so I can only speak
generically.
On Sun, 5 Dec 2004, Frank Boon [Metatronics] wrote:
> Hi,
>
> I'm researching the CATCH / THROW / ABORT matter...
> I'm using SwiftX for the AVR. I've searched in the 3 manuals: Forth
> handbook, SwiftX, SwiftX-AVR.
>
> I can't answers to the following questions:
> 1. Where does the Exception Stack reside? Within a task? and if so, is
> there a difference between background and terminal task.
The exception frames usually reside on the return stack. I don't
know of any implementations where this isn't the case.
Background and terminal tasks deal with CATCH/THROW the same way.
Beware: ABORT" will produce unpredictable results if executed from a
background task, because BACKGROUND tasks don't have I/O vectors
(TYPE, etc.) For this reason, if I can spare the room, I make ALL
tasks TERMINAL tasks, and set their I/O vectors to something safe,
e.g.:
: (NON-TYPE) ( c-addr u -- ) 2DROP PAUSE ;
: NON-TERMINAL ( -- ) ['] (NON-TYPE) 'TYPE ! ... ;
> 2. ABORT returns to the task's default Idle behavior; how is the default
> behavior determined? (background task?)
On the systems I've worked on, THROW does nothing if the caller (or
some ancestor) isn't running CATCH. This isn't obvious, and isn't
well-documented (at least, I couldn't find any discussion searching
the handbook and SwiftX manuals.)
> 3. What is a common implementation for a default exception-handler on a
> task? The following?
> : TASK_START ( exception-routine-addr task-routine-addr task-addr -- )
> ACTIVATE \ activate task
> BEGIN
> DUB CATCH \ execute the task-routine
> IF OVER EXECUTE \ error throwed : execute exception routine
> ELSE NOD \ no error throwed : stop task
> THEN
> AGAIN
> ;
You can't pass parameters "through" ACTIVATE...everything to the
right of ACTIVATE runs on the task passed to ACTIVATE, and the task
starts with empty stacks. ACTIVATE configures the task to run the
Forth code that follows it, then returns to its caller.
Here's an example for you. Hope it helps.
{ ---------------------------------------------------------------------
Typical background task
IT is the background task that runs DO-IT.
DO-IT does it.
IT-CRASHED is called to clean up the system if DO-IT crashes.
/IT gets it up and running. Note: /IT may only be called once, since
this BUILDs IT.
--------------------------------------------------------------------- }
|U| |S| |R| BACKGROUND IT
: DO-IT ( -- ) PAUSE { ... } ;
: IT-CRASHED ( throwcode -- ) DROP ;
: /IT ( -- ) IT BUILD IT ACTIVATE
BEGIN
['] DO-IT CATCH ?DUP IF IT-CRASHED /STACKS THEN
AGAIN ;
-- Ron Oliver <roliver_at_openesque.com> ---------------------------------------------------------------------- swiftx_at_forth.com The SwiftX programming discussion email list To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com For list command help, send subject "help" to swiftx-request_at_forth.com Message archives are located at http://www.forth.com/archive/swiftx ---------------------------------------------------------------------- This list is a forum for SwiftX users. For product support and bug reports, please send email to support_at_forth.com ----------------------------------------------------------------------Received on Mon Dec 06 2004 - 10:11:14 PST
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:50 PST