1. RE: Multiple loops interrupt each other :(

Weichel wrote:
> 
> 
> Hello list,
> 
> I have a couple of loops that I want to run in parallel but, when I 
> start
> number two the first stops and vise versa.
> When I stop number two number one will continue.
> 
> Each loop are in a procedure for itself and I am using the IDE to 
> develop
> the program.

Short answer: you can't. 
Euphoria does not have threads. 

You might be able to write some tricky code which might appear to 
operate in parallel, but it would be: 1. tricky, and 2. not actual 
parallel processing.

Irv

new topic     » topic index » view message » categorize

2. RE: Multiple loops interrupt each other :(

>From: Weichel <steen.weichel at deepspace.dk>
>To: Euphoria mailing list <EUforum at topica.com>
>Subject: Multiple loops interrupt each other :(
>
>Hello list,
>
>I have a couple of loops that I want to run in parallel but, when I start
>number two the first stops and vise versa.
>When I stop number two number one will continue.
>
>Each loop are in a procedure for itself and I am using the IDE to develop
>the program.
>

  This is currently impossible. Euphoria does not have concurrency, threads, 
or even thread-safety. The fact that threads aren't built-in is no big deal, 
because there are external libraries to implement it. However, the fact that 
Euphoria is not thread-safe, means we can't even use those libraries. The 
only thing you can do is merge the two loops so that they do both things in 
one loop.

>Thanks in advance for any input on this.
>
>Regards,
>
>Steen Weichel
>

new topic     » goto parent     » topic index » view message » categorize

3. RE: Multiple loops interrupt each other :(

On 12 Jan 2004, at 22:59, I Mullins wrote:

> 
> 
> Weichel wrote:
> > 
> > 
> > Hello list,
> > 
> > I have a couple of loops that I want to run in parallel but, when I 
> > start
> > number two the first stops and vise versa.
> > When I stop number two number one will continue.
> > 
> > Each loop are in a procedure for itself and I am using the IDE to 
> > develop
> > the program.
> 
> Short answer: you can't. 
> Euphoria does not have threads. 
> 
> You might be able to write some tricky code which might appear to 
> operate in parallel, but it would be: 1. tricky, and 2. not actual 
> parallel processing.

Two ways you can do this, and both means two separate programs:

1) use dde, socks, or ipc to link two apps
2) use the windows server in the archives, it's like win3.1 in written Eu!

Kat

new topic     » goto parent     » topic index » view message » categorize

4. RE: Multiple loops interrupt each other :(

> From: Kat  
> On 12 Jan 2004, at 22:59, I Mullins wrote:
> 
> > 
> > Weichel wrote:
> > > 
> > > 
> > > Hello list,
> > > 
> > > I have a couple of loops that I want to run in parallel 
> > > but, when I start number two the first stops and vise versa.
> > > When I stop number two number one will continue.
> > > 
> > > Each loop are in a procedure for itself and I am using the IDE 
> > > to develop the program.
> > 
> > Short answer: you can't.
> > Euphoria does not have threads. 
> > 
> > You might be able to write some tricky code which might appear to
> > operate in parallel, but it would be: 1. tricky, and 2. not 
> > actual parallel processing.
> 
> Two ways you can do this, and both means two separate programs:
> 
> 1) use dde, socks, or ipc to link two apps
> 2) use the windows server in the archives, it's like win3.1 
> in written Eu!

Here's another: use timers instead of loops.  You're using the IDE, so I 
assume you're running under Windows.  Set a couple of timers, and run 
one iteration of the loop for each time the timer fires.  The other 
question I would ask is, what are you trying to do in the two loops?  
Maybe there's a different (better?) way to do it.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

5. RE: Multiple loops interrupt each other :(

I am trying to merge bit patterns for the parallel port data segment that is
the 8 data out registers.

I have one stepper running one the four first bits, the other on the next
four bits.
Of course writing only to set a bit state for only one of the motors, will
also set the bits of the other motor.
So i have to merge the bit patterns into one bit pattern output for the port
which provides the required state for both motors.

I think I will try to make three seperate programs: one for each motor and
then a third that will take data from the two motor programs and only do the
writing
to the port of the assembled bit pattern. A bit like Kat is suggesting.

Any comments? and thanks for the advice.

Steen Weichel

-----Original Message-----
From: Matt Lewis [mailto:matthewwalkerlewis at yahoo.com]
Sent: 13. januar 2004 12:28
To: EUforum at topica.com
Subject: RE: Multiple loops interrupt each other :(






> From: Kat
> On 12 Jan 2004, at 22:59, I Mullins wrote:
>
> >
> > Weichel wrote:
> > >
> > >
> > > Hello list,
> > >
> > > I have a couple of loops that I want to run in parallel
> > > but, when I start number two the first stops and vise versa.
> > > When I stop number two number one will continue.
> > >
> > > Each loop are in a procedure for itself and I am using the IDE
> > > to develop the program.
> >
> > Short answer: you can't.
> > Euphoria does not have threads.
> >
> > You might be able to write some tricky code which might appear to
> > operate in parallel, but it would be: 1. tricky, and 2. not
> > actual parallel processing.
>
> Two ways you can do this, and both means two separate programs:
>
> 1) use dde, socks, or ipc to link two apps
> 2) use the windows server in the archives, it's like win3.1
> in written Eu!

Here's another: use timers instead of loops.  You're using the IDE, so I
assume you're running under Windows.  Set a couple of timers, and run
one iteration of the loop for each time the timer fires.  The other
question I would ask is, what are you trying to do in the two loops?
Maybe there's a different (better?) way to do it.

Matt Lewis



TOPICA - Start your own email discussion group. FREE!


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.536 / Virus Database: 331 - Release Date: 03-11-2003

---

new topic     » goto parent     » topic index » view message » categorize

6. RE: Multiple loops interrupt each other :(

The problem is that the motors are for driving a telescope.

One axis tracks the earth rotation and have a constant but tunable rate +
the option for slowing down or speeding up at a mouse click.
Other axis corrects error in misalignment to earth axis that is it may have
a slight constant drift in one direction +  the option for slowing down or
speeding up at a mouse click.
So in the loops you have varying step speeds, currently controlled by a
time() fkt. and a time constant after which the loop continues to the next
step (4 steps for the four coils in the motor, then back again).
All speeds are controlled by varying the time between steps for each motor.
This is all working fine, but only one motor at a time.

Therefore is I have to use only one loop it's very difficult not to have one
motor stepping rate influenced by the rate of the other.

Steen Weichel

-----Original Message-----
From: C. K. Lester [mailto:euphoric at cklester.com]
Sent: 13. januar 2004 21:06
To: EUforum at topica.com
Subject: Re: Multiple loops interrupt each other :(




Weichel wrote:

>I am trying to merge bit patterns for the parallel port data segment that
is
>the 8 data out registers.
>
>I have one stepper running one the four first bits, the other on the next
>four bits.
>Of course writing only to set a bit state for only one of the motors, will
>also set the bits of the other motor.
>So i have to merge the bit patterns into one bit pattern output for the
port
>which provides the required state for both motors.
>
>Any comments? and thanks for the advice.
>
>
For each time interval, why not just read the whole port and have it
process all the data? I don't get it (but that's not unusual). :)

-- pseudo-code follows
while i_say_go do
  x = read_port()
  y = left_4_bits(x)
  z = right_4_bits(x)

  y = process(y)
  z = process(z)

  x = combine(y,z)

  write_to_port( x )
end while



TOPICA - Start your own email discussion group. FREE!





---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.536 / Virus Database: 331 - Release Date: 03-11-2003

---

new topic     » goto parent     » topic index » view message » categorize

7. RE: Multiple loops interrupt each other :(

On 13 Jan 2004, at 20:40, Weichel wrote:

> 
> 
> I am trying to merge bit patterns for the parallel port data segment that is
> the
> 8 data out registers.
> 
> I have one stepper running one the four first bits, the other on the next
> four bits.
> Of course writing only to set a bit state for only one of the motors, will
> also set the bits of the other motor.
> So i have to merge the bit patterns into one bit pattern output for the port
> which provides the required state for both motors.
> 
> I think I will try to make three seperate programs: one for each motor and
> then a third that will take data from the two motor programs and only do the
> writing to the port of the assembled bit pattern. A bit like Kat is
> suggesting.
> 
> Any comments? and thanks for the advice.

You OR the bit pattern to write to the port:

11110000 -- motor 1 drive pattern
OR
00000011 -- motor 2 drive pattern
=
11110011 -- this goes out the port

Syntax:	x3 = or_bits(x1, x2)

Description:	Perform the logical OR operation on corresponding bits in x1 
and x2. A bit in x3 will be 1 when a corresponding bit in either x1 or x2 is 1

You shouldn't use a multitasking platform that virtualises the ports anyhow, 
since the OS could determine when the ports are written to, and could cause 
data loss when you cannot read the port in proper time. I would not use C, 
but i would use dos...., i might even be pushed to using a device driver. I 
think there is one or 3 in the archives. Or use a driver board, with 
programmable speed and ramp settings.

For ease of use in dos, didn't someone put a gui for dos into the archives? 
While MSdos isn't threaded, it can be made to thread. DRdos can thread, 
prolly better than winxx (i dunno, i have not been able to get drdos running 
here, i think Caldera bought it only so they could sue MS, they had no 
interest in actually supporting DRdos.).

Kat,
envies users of DRdos

new topic     » goto parent     » topic index » view message » categorize

8. RE: Multiple loops interrupt each other :(

Isaac Raway wrote:
> 
> 
> He wants to run multiple loops at the same time. Sounds like threads to 
> me...using timers or other solutions came up because we can't do threads 
> 
> in Euphoria (by the way, are we sure about that?).
> 
> But, the langwar system is defiantly interesting. Probably about the 
> best you could do with a pure Euphoria solution. My only gripes with it 
> might be that it's resolution is sort of unclear, and that it's 
> management of tcb variable could be a bit better (such as growing by 
> several spaces instead of one at a time).
> 
> I think Multimedia Timers are still the way to go. But...now that I 
> think about it again, I don't know if it's possible because you have to 
> pass timeSetEvent a procedure address...we can't do that can we? Oh 
> well.

Yes, with the callback function, see %eudir%\HTML\lib_c_d.htm

If that does not hyperlink, just copy and past it to the address bar in 
Internet Explorer (or whatever you use).

> 
> Feature for 2.5: Threads.
> 
> Isaac
> 

Phil

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu