[comp.sys.mac.programmer] TMTasks and Procptrs??

davide@cs.qmc.ac.uk (David Edmondson) (12/02/89)

We need to restart our macs at a preset time in order to make
sure that they are running A/UX at 1am so that the software can
be automatically updated.  I have been trying to write an INIT
which installs a tmtask structure and procedure above bufptr
but although all the bits seem to be in place it just bombs at
the specified time.  To begin with I was using block move with
a procptr as the source location but someone pointed out that
procptrs pointed at jump tables so to simplify things I tried
poking in an assembled version of restart as given in IMII.
This also failed so I tried putting in a couple of zero bytes
since procptrs point to an integer followed by an executable
but still no cigar.

Could some kind soul point me in the right direction before I
eat this keyboard.

Witzend of London.
-- 
David Edmondson

UUCP:      davide@qmc-cs.uucp   or  ...seismo!mcvax!ukc!qmc-cs!davide
ARPA:      davide%cs.qmc@nsfnet-relay.ac.uk  Post: Dept of Computer Science
JANET:     davide@uk.ac.qmc.cs                     Queen Mary College
Applelink: UK0087                                  University of London
Telex:     893750 QMCUOL                           Mile End Road
Fax:       +44 1 981 7517                          London E1 4NS
Voice:     +44 1 975 5250                          England

oster@dewey.soe.berkeley.edu (David Phillip Oster) (12/03/89)

In article <1506@sequent.cs.qmc.ac.uk> davide@cs.qmc.ac.uk (David Edmondson) writes:
>Could some kind soul point me in the right direction before I
>eat this keyboard.

If you are running A/UX you don't want to look in Inside Mac. Vol2, you
need Inside Mac Vol 5.  The StartUp Manager chapter has info on writing
INITs, the ShutDown Manager chapter has info on restarting your Mac.

Don't put the INIT above bufPtr, do set its System Heap & Locked bits. Do
a DetachResource at INIT time, so the init runner won't dispose of you.
Don't use a VBL task, since it might not be possible to do a restart at
interrupt time. (Suppose the file system were busy.)
I would override the SystemTask trap so I'd guarantee the system being in
a good state for a ReStart.  Every five minutes, I'd do a Sec2Date call,
so my INIT would get the benefit of any daylight savings time corrections
the user made.  I'd compute the five minutes by comparing Seconds with a
local variable holding (my last call to Seconds + 60*5).  If it was not
time to call the ShutDown manager to do a restart, I'd just jump to the
old SystemTask call. (Making this whole thing a legal "head patch".)

WaitNextEvent() calls SystemTask.

> The mac is a detour in the inevitable march of mediocre computers.
> drs@bnlux0.bnl.gov (David R. Stampf)
--- David Phillip Oster          -master of the ad hoc odd hack. 
Arpa: oster@dewey.soe.berkeley.edu 
Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu