mikeoro@hubcap.clemson.edu (Michael K O'Rourke) (05/24/89)
I am trying to install a precompiled LSP unit as a VBL task. I compiled it as a CODE resource and all it does is a sysbeep(1). In the calling program i declare: HCode : Handle; HCode := GetResource('OUR ',100); { the type and number of the code rsrc} DetachResource(HCode); then i set the vblAddr field of the vblTask to be ProcPtr(HCode^). This crashes the machine every time. What's up? Michael O'Rourke
han@Apple.COM (Byron Han, wyl E. coyote ) (05/24/89)
In article <5586@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes: >I am trying to install a precompiled LSP unit as a VBL task. I compiled it >as a CODE resource and all it does is a sysbeep(1). > You do realize that VBL tasks, when they run, are run at interrupt level where calls to the Memory Manager (and calls to the Resource Manager) are not legal? A VBL task that beeps via SysBeep will need to load the 'snd ' resource for the beep which is a call to the memory manager and resource manager. This is like crossing the beams (apologies to Ghostbusters) +-----------------------------------------------------------------------------+ | Disclaimer: Apple has no connection with my postings. | +-----------------------------------------------------------------------------+ Byron Han, Communications Scapegoat At Apple, we change the world everyday. Apple Computer, Inc. ----------------------------------------- 20525 Mariani Ave, MS27Y Internet: han@apple.COM Cupertino, CA 95014 UUCP:{sun,voder,nsc,decwrl}!apple!han ------------------------------------ GENIE:BYRONHAN CompuServe:72167,1664 ATTnet: 408-974-6450 Applelink:HAN1 HAN1@applelink.apple.COM -------------------------------------------------------------------------------
mnkonar@manyjars.SRC.Honeywell.COM (Murat N. Konar) (05/24/89)
In article <5586@hubcap.clemson.edu> mikeoro@hubcap.clemson.edu (Michael K O'Rourke) writes: >I am trying to install a precompiled LSP unit as a VBL task. I compiled it >as a CODE resource and all it does is a sysbeep(1). > >In the calling program i declare: >HCode : Handle; >HCode := GetResource('OUR ',100); { the type and number of the code rsrc} >DetachResource(HCode); >then i set the vblAddr field of the vblTask to be ProcPtr(HCode^). >This crashes the machine every time. What's up? You gotta lock that baby down! SysBeep is listed as a routine that may move or purge memory. So what could be happening is that either your CODE resource is moved by the SysBeep call itself or as a result of other code and your pointer is no longer valid or when SysBeep returns it returns to an area that is no longer your code resoure. Good Luck! ____________________________________________________________________ Have a day. :^| Murat N. Konar Honeywell Systems & Research Center, Camden, MN mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar(UUCP)
ksitze@nmsu.edu (Kevin Sitze) (05/25/89)
In article: <mikeoro@hubcap.clemson.edu's message of 24 May 89 02:20:48 GMT> Michael writes: >I am trying to install a precompiled LSP unit as a VBL task. I compiled it >as a CODE resource and all it does is a sysbeep(1). > >In the calling program i declare: > >HCode : Handle; > >HCode := GetResource('OUR ',100); { the type and number of the code rsrc} >DetachResource(HCode); > >then i set the vblAddr field of the vblTask to be ProcPtr(HCode^). > >This crashes the machine every time. What's up? You might want to lock the handle, if the memory manager is in the middle of moving that handle and the VBL occures, then your task suddenly finds itself running off into nowheres-ville. To prevent fragmenting of the heap, find the size of the resource like this: ... {Previous code} SetResLoad(False); {Don't want to load in the resource as of yet} HCode := GetResource('OUR ', 100); {Get a (empty) handle to the resource} ResrvMem(SizeResource(HCode)); {Get enough space for the resource} {as low in the heap as possible (ResrvMem is used when} {allocating ptrs)} SetResLoad(True); LoadResource(HCode); {Load the resource info into memory} HLock(HCode); {Lock it in place so it'll stay valid for VBL} DetachResource(HCode); ... {Rest of installation code here} If you don't want to do the previous, then the answer is simple. Just set the ResLock flag (Using ResEdit) on the resource you want in memory and then the program reverts back to: ... HCode := GetResource('OUR ', 100); DetachResource(HCode); ... This is because all the rest of the calls given in the first example are made automatically by the resource manager. Pretty fun eh? If your problem of crashing the machine persists, then you'll have to go back to your VBL code and make sure that you aren't trying to use handles anywhere in it's code. Have fun.... -Kelesi -- +--------------------------------------------------------------------+ | From the Macintosh of: Kevin L. Sitze. This is ME: ksitze@NMSU.edu | +------------------------------------------------------+-------------+ | The difference between intelligence and stupidity is | Is this | | that intelligence has a limit. -- anonymous | better? | +------------------------------------------------------+-------------+
beard@ux1.lbl.gov (Patrick C Beard) (05/26/89)
In article <KSITZE.89May24134646@picuris.nmsu.edu> ksitze@nmsu.edu (Kevin Sitze) writes: >In article: <mikeoro@hubcap.clemson.edu's message of 24 May 89 >02:20:48 GMT> Michael writes: >>I am trying to install a precompiled LSP unit as a VBL task. I compiled it >>as a CODE resource and all it does is a sysbeep(1). >> !!!!!!!!!! ... >>This crashes the machine every time. What's up? > >You might want to lock the handle... Sorry, but the problem is much more fundamental than that: in all new systems SysBeep calls the sound manager, and with all of those clever beeps we can have as 'snd ' resources, most definitely calls the Memory manager for a nice new handle to put them in. VBL routines may NOT call routines that move or allocate memory, period, as the Memory manager is NOT reentrant (i.e. can't be called again while it is processing some other request). Hope that helps. __________________ Patrick Beard PCBeard@lbl.gov BSI, Berkeley, CA ___________________