[comp.sys.amiga] VBlank interrupt servers

svermeulen%Janus.MRC.AdhocNet.CA@UNCAEDU.BITNET (Steve Vermeulen) (09/12/88)

Sorry to post this in c.s.a but I have lost c.s.a.tech read capability
for the moment...

I am busy writing parts of the next AMUC Demo, last year I put togeather
the AMUC Scrolling Demo (Fish 117) and this year the project is
a Video Wall - or the first public showing of the Amiga 9000 :-)

As part of this I needed an exact, stable, time base that would track
across 9 Amigas for an extended period of time without drifting
between machines.  To do this I am proposing to use the VBLANK signal
and essentially keep a count of all the VBLANKS that occur.

First question:  how much drift between VBLANK counts between machines
am I likely to see over 15 minutes, 1 hour, 8 hours?

I looked into the timer device first and found that the unique time stamp
feature of this device might prevent this exact time keeping.  So
remembering the DevCON notes I looked at Steve Beats article on using
68K assembler on the Amiga.  In which Steve creates a VBLANK server
that counts vblank events and Signals another task every 60 vblanks.

This was almost exactly what I needed.

Comparing his article to the Exec RKM on page 60 where it states:

   "Servers have different register values passed than handlers do.
    A server cannot count on the D0, D1, or A6 registers containing
    any useful information."

This has caused me some head scratching, as Steve's interrupt server
USES A6 under the assumption it has a valid value of ExecBase in it
when it is called.  You see, I started with the example on pages 61-62
of RKM Exec and then added in the "jsr _LVOSignal(a6)" call and things
went nuts.  I finally traced it down to this: when my server (at priority
of -60) is called A6 is trashed (as the RKM states) but Steve's
server is added at priority +20 and this must put it high enough in the
list (probably at the head) that A6 still contains a valid pointer
to ExecBase.

Second Question: What I want to know is "AM I BRAIN DAMAGED, or is this the
correct explaination"???




                      Stephen Vermeulen
                      Author: Express Paint
                      Chairman: AMUC.

haitex@pnet01.cts.com (Wade Bickel) (09/12/88)

Hi Stephan,

        I've had particularly bad results setting the priority of the VBlank
server above 10.

        Also, by setting your priority at -60 you will be creating a variance
between VBlank cycles, as code in some of the servers (such as the IntuiTicks)
will be executoed only on some VBlanks, and by-passed on others.

        If you want real stability, you might try making a handler, and
putting your own server in front of the system's (This is a C= no no!).

        Another possibility might be to use the external interrupt pin and a
little custom hardware.  In this way the first Amiga would gather its timeing
from the VBlank, and then cause an interrupt in the next machine on the
the external interrupt line, which would cause the same to happen to the
subsiquent machine, and so on and so on and ...


                                                        Good Luck,


                                                                Wade.

UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!haitex
ARPA: crash!pnet01!haitex@nosc.mil
INET: haitex@pnet01.CTS.COM
Opionions expressed are mine, and not necessarily those of my employer.

ewhac@well.UUCP (Leo L. Schwab) (09/12/88)

In article <880911141731.00s@Janus.MRC.AdhocNet.CA> svermeulen%Janus.MRC.AdhocNet.CA@UNCAEDU.BITNET (Steve Vermeulen) writes:
>[ ... ] I needed an exact, stable, time base that would track
>across 9 Amigas for an extended period of time without drifting
>between machines.  [ ... ]
>
	I would suggest looking into the possibility of using the time-of-
day clock in the CIA chips as your timebase.  I'm 99% sure that the TOD
clocks are clocked by the AC line frequency, which will be the same for all
the machines you use.  Since the line frequency will serve as a common
timebase, synchronization will be trivial (sorta...).

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

steveb@cbmvax.UUCP (Steve Beats) (09/12/88)

In article <880911141731.00s@Janus.MRC.AdhocNet.CA> svermeulen%Janus.MRC.AdhocNet.CA@UNCAEDU.BITNET (Steve Vermeulen) writes:
>
>.............. I needed an exact, stable, time base that would track
>across 9 Amigas for an extended period of time without drifting
>between machines.  To do this I am proposing to use the VBLANK signal
>and essentially keep a count of all the VBLANKS that occur.
>
>remembering the DevCON notes I looked at Steve Beats article on using
>68K assembler on the Amiga.  In which Steve creates a VBLANK server
>that counts vblank events and Signals another task every 60 vblanks.
>
>Comparing his article to the Exec RKM on page 60 where it states:
>
>   "Servers have different register values passed than handlers do.
>    A server cannot count on the D0, D1, or A6 registers containing
>    any useful information."
>
>This has caused me some head scratching, as Steve's interrupt server
>USES A6 under the assumption it has a valid value of ExecBase in it
>when it is called.  You see, I started with the example on pages 61-62
>of RKM Exec and then added in the "jsr _LVOSignal(a6)" call and things
>went nuts.  I finally traced it down to this: when my server (at priority
>of -60) is called A6 is trashed (as the RKM states) but Steve's
>server is added at priority +20 and this must put it high enough in the
>list (probably at the head) that A6 still contains a valid pointer
>to ExecBase.
>
>Second Question: What I want to know is "AM I BRAIN DAMAGED, or is this the
>correct explaination"???
>

Er, cough, ahem ... You spotted the intentional mistake then ?

Sorry, that was a real, honest-to-goodness cock up on my part.  It did work
though, which is probably why I missed it.  I've been looking through these
manuals so long now that I often make assumptions on how something will work
(based on the way other routines in the same sub-system are called).  In most
cases this is OK, but obviously not in all of 'em.

So don't worry, your brain appears undamaged and functional.

	Steve

rminnich@super.ORG (Ronald G Minnich) (09/13/88)

How accurate do you need to be? It sounds like what you want is 
equivalent to a distributed time server. If i get this right, you 
need to be higher resolution than vblank, which i guess can go to 
60 hz. which is 16 ms. The ntp demon available for free can do much
better than this. You could use this code as a model. It is a very 
interesting piece of work. It is a distributed, self-organizing system.
If any one host goes nuts it won't drive other hosts to have the wrong time.
I have two uses for it: One, to have the time be accurate on our 
Suns. Two, more important, to keep the suns time in agreement to 
a few milliseconds or so (the limitation i understand is not the 
protocol, but sun hardware). This second use will be very important
to us once we have >100 workstations!
   You might want to take a look. The RFC i have is number QQVV or 
something so i guess it is not a real RFC yet. I can mail it to 
interested parties. Or ftp ntp.tar.Z from trantor.umd.edu. 
ron
P.S. I didn't do any of ntp stuff, but it is a beautiful piece of work!

plouff@nac.dec.com (Wes Plouff) (09/14/88)

Steven Vermeulen (svermeulen%Janus.MRC.AdhocNet.CA) writes:
>I am busy writing parts of the next AMUC Demo...
> 
>As part of this I needed an exact, stable, time base that would track
>across 9 Amigas for an extended period of time without drifting
>between machines.  To do this I am proposing to use the VBLANK signal
>and essentially keep a count of all the VBLANKS that occur.
> 
>First question:  how much drift between VBLANK counts between machines
>am I likely to see over 15 minutes, 1 hour, 8 hours?

You can get the drift to zero by genlocking Amigas 2 through 9 to 
Amiga 1, or all of them to a commercial television station.

A little back-of-the-envelope math says that if VBLANK counts occur 
every 1/60th second, and the Amiga clock oscillator has a tolerance of 
+/- .005% (just guessing here), then any two Amigas can drift a maximum 
of 2 x tolerance, or 21.6 counts per hour.
-- 
Wes Plouff, Digital Equipment Corp, Littleton, Mass.
plouff%nac.dec@decwrl.dec.com

Fantasy TV ad ending: "Except for my voice, every image and sound in
this commercial was created or processed by an Amiga.  Write us, and
we'll tell you exactly how we did it."