PDA

View Full Version : Machine Chain Problem


Jawahar
06-23-04, 02:56 PM
I am testing a code for multithreading using Machine Chain.
I have two machines that I want to run in parallel. But only the last Machine in the Machine Chain seems to be working.

Why are both the Machines not running in parallel?

---------Code--------------------

SCRUB

HEX

0 RAM !

: HALFSPEEDCPU F413 FA1 ! 82 F00 ! ; EEWORD
HALFSPEEDCPU

: -LOOPVAR
<BUILDS HERE P, 1- DUP , , DOES>
P@ DUP @ 0= IF DUP 1 + @ SWAP ! TRUE ELSE 1-! FALSE THEN ; EEWORD

DECIMAL
200 -LOOPVAR DL EEWORD

MACHINE ARBITRATE EEWORD
ON-MACHINE ARBITRATE
APPEND-STATE ARBITRATING EEWORD

IN-STATE
ARBITRATING
CONDITION
DL
CAUSES
CR ." ARBITRATING "
THEN-STATE
ARBITRATING
TO-HAPPEN IN-EE

MACHINE FIGURE_8 EEWORD
ON-MACHINE FIGURE_8
APPEND-STATE BUSY EEWORD

IN-STATE
BUSY
CONDITION
DL
CAUSES
CR ." BUSY "
THEN-STATE
BUSY
TO-HAPPEN IN-EE

MACHINE-CHAIN PIG_8
FIGURE_8
ARBITRATE
END-MACHINE-CHAIN EEWORD


ARBITRATING SET-STATE
BUSY SET-STATE

: STARTUP
CR ." STARTING UP " CR
EVERY 50000 CYCLES SCHEDULE-RUNS PIG_8
; EEWORD

( STARTUP

---------------------End of Code---------------------

RMDumse
06-23-04, 03:53 PM
You used the same delay counter in both machines. So each time, they both decrement it, or together they decrement it twice. So only one of them sees it become 0.

Try making a DL1 and DL2 and use different counters for each machine. You could even use a different count limit.

Anyway, both machines are running. It's just hard to see with the cross-connected counter set to an even number. if you run the machine independently (i.e. they have their OWN counter) I think it become obvious they are both working fine.

Jawahar
06-23-04, 04:26 PM
Thanks for the answer!