[comp.sys.mac.programmer] Using VBL Tasks in Inits...

bell@eniac.seas.upenn.edu (Mike Bell) (12/27/88)

   I've written an init that Installs a VBL task. Unfortunately, the procedure
is executed exactly once. It would seem that the vblcount value is not being
reinitialized, so the routine is being removed from the Queque; I am updating
it though. Are there any special precautions that must be taken to install a
VBL task from within an INIT.

  I would appreciate any hints,pointers, sample code, etc.....



			Thanks.

			Mike Bell
			bell@eniac.seas.upenn.edu

 

     _______________
    /  ___________  \
    | /           \ |
    | |   UPenn   | |
    | |    Mac    | | Administrator:          Mike Bell (bell@eniac)
    | |  Archives | |
    | \___________/ |  To access the Mac archives, issue the command:
    |       ______  |           cd ~mac/new
    |  ,   |______| |  For a listing of all available files, read:
    | @             |            filelist.tx
    \_______________/   Send any questions/suggestions about the archives to:
    |               |
    \_______________/                        mac@eniac

*****  Above instructions are valid for PennNet use only...all others use FTP

tim@hoptoad.uucp (Tim Maroney) (12/28/88)

In article <6865@netnews.upenn.edu> bell@eniac.seas.upenn.edu (Mike Bell)
writes:
>   I've written an init that Installs a VBL task. Unfortunately, the procedure
>is executed exactly once. It would seem that the vblcount value is not being
>reinitialized, so the routine is being removed from the Queque; I am updating
>it though. Are there any special precautions that must be taken to install a
>VBL task from within an INIT.

_Launch and its sister _ExitToShell both remove all VBL tasks that are not
in the system heap.  Both the queue element and the code address it points
to must be in the system heap to survive the launching of an application
or the Finder.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"Religion flourishes in greater purity without than with the aid
 of government." -- James Madison

imp@crayview.msi.umn.edu (Chuck Lukaszewski) (12/28/88)

In article <6865@netnews.upenn.edu>, bell@eniac.seas.upenn.edu (Mike Bell) writes:
> 
>    I've written an init that Installs a VBL task. Unfortunately, the procedure
> is executed exactly once. It would seem that the vblcount value is not being
> reinitialized, so the routine is being removed from the Queque; I am updating
> it though. Are there any special precautions that must be taken to install a
> VBL task from within an INIT.

Since the VBL task must be executed in order to refresh the queue entry, I
would surmise that the code itself is no longer present.  You will want to
put your code in the system heap, or drop BufPtr and install it in high 
memory.  This will ensure that it doesn't go away.  If your process is intended
to be permanent once the system is booted, you ought to go with the high
memory option.

______________________________________________________________________________
Chuck Lukaszewski          imp@crayview.msi.umn.edu               612 789 0931

holland@m2.csc.ti.com (Fred Hollander) (12/29/88)

In article <10569@umn-cs.CS.UMN.EDU> imp@crayview.msi.umn.edu (Chuck Lukaszewski) writes:
>memory.  This will ensure that it doesn't go away.  If your process is intended
>to be permanent once the system is booted, you ought to go with the high
>memory option.

Ok, what's the consensus on this?  I'm not criticizing this suggestion.  I
would just like to know the right way to do this, since I'm writing my own
INITs to patch system traps.  I've been loading them into system heap as I
believed this was the popular way to do it.  What are the drawbacks of loading
in high memory?

>______________________________________________________________________________
>Chuck Lukaszewski          imp@crayview.msi.umn.edu               612 789 0931

Fred Hollander
Computer Science Center
Texas Instruments, Inc.
holland%ti-csl@csnet-rela

The above statements are my own and not representative of Texas Instruments.

tim@hoptoad.uucp (Tim Maroney) (12/29/88)

In article <10569@umn-cs.CS.UMN.EDU> imp@crayview.msi.umn.edu (Chuck
Lukaszewski) writes:
>
>Since the VBL task must be executed in order to refresh the queue entry, I
>would surmise that the code itself is no longer present.  You will want to
>put your code in the system heap, or drop BufPtr and install it in high 
>memory.  This will ensure that it doesn't go away.  If your process is intended
>to be permanent once the system is booted, you ought to go with the high
>memory option.

Correct me if I'm wrong, but I believe a VBL task in above BufPtr memory
will be automatically removed on _Launch.  The OS does a simple "higher
than bottom of application zone" test, not "between app. zone and BufPtr",
to determine what to remove from the queue.  If you want to keep the code
above BufPtr, allocate a six-byte pointer in the system heap, put 0x4e75
(JMP.L) in the first word, and the routine pointer in the last longword,
then set your VBL queue entry function pointer to that sys. heap pointer.
And of course, the queue element itself must also be a sys. heap pointer.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"Conversion, fastidious Goddess, loves blood better than brick, and feasts
 most subtly on the human will." - Virginia Woolf, "Mrs. Dalloway"

siegel@endor.harvard.edu (Rich Siegel) (12/29/88)

In article <6119@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes:
>above BufPtr, allocate a six-byte pointer in the system heap, put 0x4e75
>(JMP.L) in the first word, and the routine pointer in the last longword,

	Just to set the record straight, you'll want to use $4EF9, which
is an absolute long JMP. $4E75 is an RTS....

R.



Rich Siegel
Staff Software Developer
THINK Technologies Division, Symantec Corp.
Internet: siegel@endor.harvard.edu
UUCP: ..harvard!endor!siegel
Phone: (617) 275-4800 x305

Any opinions stated in this article do not necessarily reflect the views
or policies of Symantec Corporation or its employees.