Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Q: Multithreading/processing & HERE

0 views
Skip to first unread message

Alex McDonald

unread,
Mar 22, 2003, 12:02:09 PM3/22/03
to
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. 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


Elizabeth D. Rather

unread,
Mar 22, 2003, 3:08:19 PM3/22/03
to
Alex McDonald wrote:

> 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


Gary Chanson

unread,
Mar 22, 2003, 3:25:45 PM3/22/03
to

"Alex McDonald" <alex...@btopenworld.com> wrote in message
news:b5i4ug$iph$1...@hercules.btinternet.com...

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.


Albert van der Horst

unread,
Mar 23, 2003, 6:46:52 AM3/23/03
to
In article <b5i4ug$iph$1...@hercules.btinternet.com>,

Alex McDonald <alex...@btopenworld.com> wrote:
>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. Which leads to:

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

Alex McDonald

unread,
Mar 25, 2003, 3:14:47 PM3/25/03
to

"Albert van der Horst" <alb...@spenarnc.xs4all.nl> wrote in message
news:HC7A24.GI6...@spenarnc.xs4all.nl...

> In article <b5i4ug$iph$1...@hercules.btinternet.com>,
> Alex McDonald <alex...@btopenworld.com> wrote:
> >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. Which leads to:
>
> 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

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


0 new messages