View Full Version : Threads using Macros
Sangfroid
05-31-04, 12:55 AM
Hi,
I am a newbie in the Isopod environment.
I wud like to know "How to do threading using macros"?
I am using the machine-chain word to chain several machines together. I want these machines to run parallely.
Thanx in advance
nmitech
06-01-04, 02:06 PM
Sangfroid, what do you mean by "How to do threading using macros"? Can you be more specific on this?
I am using the machine-chain word to chain several machines together. I want these machines to run parallely.
MACHINE-CHAIN is the correct word to make several state machines run simultaneously. Of course, since this is a single CPU, they don't truly run in "parallel". What happens is the machines run as nearly simultaneously as the processor can manage, which gives the appearance of the machines running in parallel.
Sangfroid
06-01-04, 04:07 PM
I am using several macros in my program. I have one-state machines wherein I call the respective macros in the states. All the machines are chained. This is the current status.
By "How to do threading using macros", i meant if I cud do away with the single-state machines and still trigger the macros together or in a way run the macros as parallel threads.
nmitech
06-02-04, 12:04 PM
If by "macros" you mean a high level definition of the form
: <name> ...definition... ;
or a "PROC" defintion of the form
DEFINE <name> PROC ...definition... END-PROC
then yes, with care you can insert these into a machine chain. There's no need to define a single-state machine just to perform one of these functions. But you must be VERY careful that your macros leave the stack as they found it -- they can use the stack internally, but must not remove any values that were already on the stack, and must not leave any extra values on the stack.
Suppose you have macros FOO1 and FOO2, always performed by the single state machines MACHINE1 and MACHINE2, and you also have complex state machines MACHINE3 and MACHINE4. You could replace
MACHINE-CHAIN
MACHINE1
MACHINE2
MACHINE3
MACHINE4
END-MACHINE-CHAIN
with this:
MACHINE-CHAIN
FOO1
FOO2
MACHINE3
MACHINE4
END-MACHINE-CHAIN
Is that what you're trying to do?
Sangfroid
06-04-04, 08:59 AM
Thanx nmi, that is what i was looking for!!
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.