Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ll-xn!adelie!munsell!jdj
From: jdj@munsell.UUCP (Joel Jennings)
Newsgroups: comp.sys.amiga.tech
Subject: Need info on exceptions
Summary: How can I make my code interrupt to call exception rtn?
Message-ID: <1754@munsell.UUCP>
Date: 18 Aug 88 21:06:06 GMT
References: <4989@pasteur.Berkeley.EDU> <566@wuphys.UUCP>
Reply-To: jdj@munsell.UUCP (Joel Jennings)
Organization: Eikonix Corp., Bedford, MA
Lines: 76


Hello to everyone from a new reader.

I am looking for a way to cause my program to take an exception periodically
so that it can write out intermediate results of a long calculation* (see
below). Essentially, I would like something similar to the Unix 
'signal(SIGALRM,save_rtn)' function, so that every 10 minutes or so my
program can checkpoint where it is in the calculation in case the system
crashes. Upon rebooting, I can reaload the checkpoint info and continue
from there with no more than 10 minutes or so lost.

    1) I have references in one of my manuals to a "SigExcept" function,
         which looks to be exactly what I need. Unfortunately, there is
         no definition of the function, its arguments, return codes, etc
         in that manual, nor is there one in my ROM kernel manuals. 
         Furthermore, there is no entry in any of my libraries or include
         files for this function. If this is what I need to use, can anyone
         tell me where to find the subroutine description and directions
         on how to use it?

    2) That same manual in #1 refers to entries in the task structure named
         "ExceptCode, ExceptData, and . I
         have tried putting the address of my routine there and stuffing the
         signal mask of the (to be delivered) timer message into the signal
         area, but this doesn't seem to force a subroutine call when the
         message is delivered. I can block for the message, but the routine
         is never called. Do I need any more steps to set this up? (This
         is a hack and I would rather use a system supplied routine.)

    3) Worst comes to worst, I have been considering running a separate
         timing task which has received a message from the calculation task 
         containing (ready for this?) the address of the calculation data.
         After receiving the data address, the calculation task can loop on
         a 10 minute wait writing out the *other* tasks data. Since the Amiga
         is a true timesharing machine, the calculation task will be running
         while the timing task waits. This is a very bad solution. Can anyone
         suggest a better idea?

----------------------------------------------------------------------------
*: Explanation of long calculation follows - hit 'N' if you don't care,

    I don't use my Amiga much of the time (like, when I'm asleep or at work),
and so I thought I'd put it to work discovering the secrets of the universe
while I'm not there. Specifically, I wanted to find the next minimum golomb
ruler (I think that would be 14 marks, but I don't have my notes with me
right now). A golumb ruler is a ruler with N marks on it (each mark an exact
number of inches from the first mark, which is at 0 inches) such that the
distance between any two marks is not duplicated between any other two marks.

    For example, a golumb ruler with two marks has marks at 0 and 1. It can
measure one distance: 1.

    A golumb ruler with 3 marks has marks at 0, 1, 3. It can measure 3
distances: 1, 2 (the difference between 1 and 3), and 3.

    A golumb ruler with 4 marks has marks at 0, 1, 3, 7. It can measure 6
distances: 1, 2, 3, 4 [7 - 3], 6, and 7.

    A minimum golomb ruler with N marks is the shortest such ruler. As shown
in the 3rd example, not every distance need be available, as long as there
is not two ways to make any of the distances. 

    Time calculations indicate that to find all minimal rulers of N marks
takes 10 times the amount of time to find all rulers of
N-1 marks. In order to push back the envelope of current knowledge about 
golomb rulers to beyond 14 would take 412 straight days of computing time.
The AC *LINE CURRENT* in my apartment won't stay up that long without 
interruption, much less an Amiga with a (gasp!) hard disk. Any attempt to
put systime/checkpoints in the code would only make the calculation run much
longer.

    (Anyone out there know where I can get access to 10 Amigas for 1.5 years
to find all rulers of length 15? :-)
-- 

Joel Jennings   | Wampeters, foma, and granfaloons.
                |