FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
FAST Forth Native-Language Embedded Computers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
F-PC<br />
1 Parallel <strong>Forth</strong>:<br />
The New Approach<br />
Michael Montvelishsky<br />
Saransk, Russia<br />
As a rule, the arrival of a new programming language<br />
is caused by the arrival ofsome new programming method<br />
or paradigm. Thus, Algol-60 marked the appearance of the<br />
structured programming approach, and Pascal heralded<br />
the advanced user-defined data types. Object-oriented<br />
programming was born coupled with Smalltalk, but C++<br />
has marked its entrance into the professional leagues. New<br />
programming paradigms demand new programming languages.<br />
But <strong>Forth</strong> users need not change languages<br />
because, of course, <strong>Forth</strong> is extensible and can easily<br />
adopt new paradigms. The subject of this paper demonstrates<br />
how <strong>Forth</strong> can adapt a parallel programming<br />
paradigm.<br />
One of the hot areas of programming science is<br />
"parallel computing." C.A.R. Hoare, author of Communication<br />
Sequential Processes is the first theoretical founder<br />
of parallel computing. The programming language Occam<br />
is based on Hoare's theory. It is considered to be one of<br />
the main parallel-programming languages. There are two<br />
major features of this interesting language:<br />
I I used.<br />
<strong>Forth</strong> users need not change<br />
languages-because <strong>Forth</strong> is<br />
extensible, it can easily adopt<br />
new programming paradigms.<br />
1. Channels for information exchange and synchronization<br />
between processes.<br />
2. The ability of the currently running process to run<br />
several (the number may be very large) "son" parallel<br />
processes. Parent processes stop themselves and run<br />
son processes, then they start to run again after all son<br />
processes are done.<br />
Another popular parallel programming model is Linda<br />
by D. Gelernter. Linda is not a programming language, but<br />
a parallelizing extension to a conventional programming<br />
language. There is C-Linda, Fortran-Linda and <strong>Forth</strong>-<br />
Linda. Linda's paradigm is based on the idea of active and<br />
passive tuples. Active tuples are processes started by some<br />
other process and running with it cooperatively. Passive<br />
tuples are tools for information exchange; they exchange<br />
information like notes on a bulletin board.<br />
Paradigms of Occam and Linda do not conflict with one<br />
another, but rather complement each other. It is hard to<br />
emulate Linda in Occam, and it is hard to emulate Occam<br />
in Linda efficiently.<br />
The subject of this paper is a parallel extension to <strong>Forth</strong>.<br />
What new has arrived with Parallel <strong>Forth</strong> Very little: see<br />
the glossary on the next page.<br />
Several notes, about the source code:<br />
1. All the user variables of a son that is defined in a<br />
program have the same values as those of its parent<br />
before I I ( ... ) or EV ( ... ) constructions. Thus, it's<br />
possible to use user variables to pass parameters from<br />
a parent to a son, or to a cooperative parent.<br />
2. Make sure the user area and stack size for each process<br />
are big enough to run without hanging up. It's easy to<br />
write special words to fill these areas with some<br />
character and then to see how many of them were<br />
3. If you mount a son process' ring with I I ( ... ) , you<br />
can't run co-operatively with EV ( ... ) until PAR starts<br />
the ring - where the EV ( ... ) is at.<br />
4. There is automatic memory allocation for I I ( ... ) and<br />
EV ( ... ) processes. But automatic memory deallocation<br />
is only for I I ( ... ) processes (and all processes inside<br />
them)! Can you guess why<br />
5. All processes start with empty stacks.<br />
Now, about the programs. The source of the parallel<br />
<strong>Forth</strong> extension is in Listing One. I've used F-PC ver. 3.53.<br />
It's one of most complete <strong>Forth</strong>s for IBM-PC compatibles,<br />
and it's public domain! The source doesn't contain code<br />
words, so you can transfer it easily to another <strong>Forth</strong><br />
platform with only minor changes. You can rewrite PAUSE<br />
in assembler to increase efficiency, but the best way is to<br />
implement Parallel <strong>Forth</strong> on some real multi-processor<br />
hardware.<br />
A sample program is shown in Listing Two @age 191.<br />
I've chosen a scalar vector multiplication as an example of<br />
using the parallel wordset. The task is like task X4 from<br />
<strong>Forth</strong> Dimensions 15 March 7994 April