1. ANS Forth does not permit re-entrancy. Definitions of HERE , : etc assume
a single task. Which leads to:
2. ANS Forth requires locking in pre-emptive multitasking systems (note the
pre-emptive).
CREATE A 0 , 0 , 0 ,
would require
LOCK HERE CREATE A 0 , 0 , 0 , UNLOCK HERE
What words would require locking support? I would suspect (CORE only);
HERE
VALUE and VARIABLE references by ! @ et al
: and ;
EVALUATE (side effects of evaluated words)
EXECUTE (ditto)
FIND
etc.
I've know I'm driving up the wrong path. How _is_ concurrency & reentrancy
acheived in Forth on a pre-emptive or multi-processor system?
--
Regards
Alex McDonald
> Give a single thread/task Forth, then no locking/syncing is needed for words
> such as HERE (I'll focus on HERE, but many other words are affected by the
> same requirment). Some observations:
>
> 1. ANS Forth does not permit re-entrancy. Definitions of HERE , : etc assume
> a single task.
Re-entrancy is simple if each task has its own environment (stacks, HERE, etc.),
with no locking required on these items.
> ...
>
> I've know I'm driving up the wrong path. How _is_ concurrency & reentrancy
> acheived in Forth on a pre-emptive or multi-processor system?
By ensuring that each task runs in its own execution environment, as noted
above. Given that, all you need to protect is things involving variables or
other data structures in shared memory (and even then you can make them
USER variables, which means each task has its own copy).
Cheers,
Elizabeth
This is only true if more then one task compiles code into the same
dictionary. In most cases, only one task is every permitted to compile code.
In cases where this is not true, the tasks typically have separate dictionary
segments to compile to so no locking is needed.
--
-Gary Chanson (MS MVP for Windows SDK)
-Software Consultant (Embedded systems and Real Time Controls)
-gcha...@mvps.org
-War is the last resort of the incompetent.
In principle ISO allows a lot. It guarantees little.
In Forth's that support multi-tasking HERE is typically defined as
: HERE DP @ ; where DP is a so-called user variable. This means that
there is a fresh instance of DP for each task.
This practice doesn't conflict with ISO.
>Alex McDonald
--
Groetjes Albert
--
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
Q.: Where is Bin? A.: With his ma. Q.: That makes the Saudi's
terrorists, then? A.: No, George already owns their oil.
alb...@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst
Aha! The light's have just come on. Sorry for being so stupid... I've been
staring down the wrong end of the telescope.
> there is a fresh instance of DP for each task.
> This practice doesn't conflict with ISO.
>
> >Alex McDonald
> --
> Groetjes Albert
> --
> Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
> Q.: Where is Bin? A.: With his ma. Q.: That makes the Saudi's
> terrorists, then? A.: No, George already owns their oil.
> alb...@spenarnc.xs4all.nl http://home.hccnet.nl/a.w.m.van.der.horst
Thanks to other posters too.
--
Regards
Alex McDonald